srthomso 0 Newbie Poster

Cheers m8 u're a diamond! that certainly has helped! i'm thinkin of doin a java course, so any little helpful hinters are great!
Thanks again.
Steve

srthomso 0 Newbie Poster

hehe, cheers but i managed to sort it out myself. Thanx
Steve

srthomso 0 Newbie Poster

Could anyone give me a hand with my mock exam, i'm on msn - get_jiggy_widit@hotmail.com. I'm struggling a bit - with some of the simple things really n it's getting on my nerves.
Any help would be greatly received.
Thanks
Steve

srthomso 0 Newbie Poster

I'm not sure I quite understand what you have done here:-S

srthomso 0 Newbie Poster

I have some code which examines an array to see if it contains a particular value:

boolean found = false;

int []a = new int[100];

populate(a); // populates the array a with a set of random values

int valueToFind = 123;  // or whatever we want to find

while((n < 100) && (! found)){
    if(a[n] == valueToFind){
        found = true;
    }
    else {
        n = n + 1;
    }
}

However i'm struggling with re-coding this as a function with parameters and/or a return value to be able to work with any size array.

Then how could I create a second function to give me a value stored in a particular location on the array?

Why is programmin so difficult to learn?! lol

Hope some1 can help, thanks

Steve

srthomso 0 Newbie Poster

Greetings.
What would you like to do in order to trigger the loop?
When the input given is none other than "play" or "end" ?

I dont quite understand wot u mean? Sorry i'm new to all this language malarky.

Ste

srthomso 0 Newbie Poster

code:

public static void menu(){
    String reply;
    System.out.println("Make your choice:");
    reply = getLineFromUser(); //assume this function works correctly
    if(reply.equals("play")){
         playgame();
    }
    else
        if(reply.equals("end")){
           stopGame();
        }
   menu(); // recursive call. Don't use!!!!!    

Any ideas? i struggle with while loops at the best of times.

srthomso 0 Newbie Poster

Cheers guys - how stupid do i feel now. told ya it'd be somethin simple.

srthomso 0 Newbie Poster

I've come up with some code to try and reject ages outside the range of 18 to 64, but i cant seem to find my errors or how to fix it. Feel stupid as its probably somethin easy, but i'm just learnin the language, can you help:

int age;
age = getIntFromUser(); // assume this function works correctly
if(age < 18 && > 65){
System.out.println("age is accepted: please continue");
}
else {
System.out.println("age rejected: program terminating");
}

srthomso 0 Newbie Poster

Thank you very much for your help - much appreciated!

srthomso 0 Newbie Poster

here's the code:

string reply;
reply = getLineFromUser(); //assume this function works correctly
if(reply == "JAVA"){
System.out.println("OK to continue");
}
else {
System.out.println("Error - try again!");
}

i cant seem to see where i'm going wrong, thus cant get a correct version to work. I need it to keep repeating asking for a passwrod until its correct. Password equals JAVA.
Hope some1 can help, cheers.