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
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
hehe, cheers but i managed to sort it out myself. Thanx
Steve
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
I'm not sure I quite understand what you have done here:-S
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
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
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.
Cheers guys - how stupid do i feel now. told ya it'd be somethin simple.
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");
}
Thank you very much for your help - much appreciated!
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.