Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please Help arrays

 
nathan Drake
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help I am really confused

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
Marshal
Pie
Posts: 21412
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's supose to be java using notepad
 
Henry Wong
author
Marshal
Pie
Posts: 21412
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic