This week's book giveaway is in the Kotlin forum.We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

nathan Drake
Greenhorn
Posts: 2

I am really stuck with this can anyone help?

A function ARRTEST is specified below
function ARRTEST (arr in Array of Char)return in Array of Int
pre the array arr is full
post the returned value is an array of the same size as arr
in the returned array,the value at index position i is
1 if the character in arr at index positon i is upper case letter
-1 if the character in arr at index position i is lower case letter 0 otherwise

A partial implementation of ARRTEST is given but with some details omited (these are shown by 1 to 5 in the comments)Give appropriate code to complete the implementation (It is sufficient to give the code required at each (1) to (5)

function ARRTEST(arr)
{
var index in Int
var outArr in Array (of size SIZE(arr)) of Int
var oldVal in Char
var newVal in Int
for (index<--/*(1) – out in bounds*/)
{
/*(2) Set oldVal to the value at position index in arr. */
/* Examine oldVal, and set newVal to be the appropriate integer in the returned array. */
newVal<-- 0
if (/* (3) – out in condition */)then
{newVal<-- 1}
if (/*(4)- put in condition */) then
{newVal<-- -1}
/* (5) – use newVal to fill each position in outArr. */
}
return outArr
}

Henry Wong
author
Sheriff
Posts: 23283
125
Java and Javascript are *not* the same thing. Moving this topic to the Javascript forum.

EDIT: Now that I look at this a bit more.... What language is this???

Henry

nathan Drake
Greenhorn
Posts: 2
It's supose to be java using notepad

Henry Wong
author
Sheriff
Posts: 23283
125
nathan Drake wrote:It's supose to be java using notepad

It isn't Java... not even close. For example...

Java doesn't have the "function" keyword (assuming method/function declaration). And Java requires that you specify the type of the parameters.

Java doesn't have the "var" keyword (assuming local variable declaration).

There are also more stuff following... these are just the first few indicators.

Henry

Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
It looks close to JavaScript, but isn't.

Where did you get the reference for this language? It's not even close to Java, and is similar to, but isn't, JavaScript.

What are you trying to write?

 Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters?