aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Please Help arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Please Help arrays" Watch "Please Help arrays" New topic
Author

Please Help arrays

nathan Drake
Greenhorn

Joined: Nov 28, 2009
Posts: 2
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
Sheriff

Joined: Sep 28, 2004
Posts: 18847
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
nathan Drake
Greenhorn

Joined: Nov 28, 2009
Posts: 2
It's supose to be java using notepad
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18847
    
  40

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

Joined: Jan 10, 2002
Posts: 61232
    
  66

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Please Help arrays