QUOTE(Martyr2 @ 1 Dec, 2008 - 02:39 PM)

Oh come on grayzer, I have done half of the assignment for you already and you didn't even TRY to produce a loop in your main function. Look in your book or on the net of how a loop is constructed, put it in the main function around where you ask for user input and check it against the random number and you will see you can probably set it up in about 15 - 20 minutes.
Give it a try at least and show us what you come up with. If you run into troubles that is what we are here to help for.

Hi Martyr2,
i've been trying different loops all evening and I just can't get my head around it - I didn't realise I uploaded the program without the loop I put in. Have look and see what you think cos I'm probably going off in the wrong direction.
Thanks, grayzer.
CODE
import java.util.Random;
import java.util.Scanner;
public class Game
{
public static Random generator = new Random();
private static Scanner s = new Scanner(System.in);
public static void main(String args[])
{
int i = 0;
while (i < 10)
{
i++;
{
int numberOne, numberTwo;
// Generate a random number
numberTwo = generator.nextInt(10);
System.out.println("Random number is " + numberTwo);
// Prompt the user for a number
System.out.println("Enter your number: ");
numberOne = s.nextInt();
System.out.println("Your number is " + numberOne);
// Check guess against random number
checkAgainstRandomNumber(numberOne, numberTwo);
}
private static void checkAgainstRandomNumber(int num1, int num2)
{
// Compare the numbers
if (num1 == num2) {
System.out.println("You have won");
}
else if (num1 > num2) {
System.out.println("Your number is too high");
}
else {
// If it is not equal or not greater than, it can only be less than
// So you can skip the test.
System.out.println("Your number is too low");
}
}
}