i'm supposed to be creating a "game" that assigns a random number and allows user to guess the number, it is then supposed to display the amount of guesses made. just wondering what i'm missing since I cant currently get it to compile... wouldn't mind having my errors pointed out.
// ---------1---------2---------3---------4---------5---------6---------7
// 1234567890123456789012345678901234567890123456789012345678901234567890
import java.util.Scanner;
import java.util.Random;
public class RandomNumbersGame
{
public static void main(String[] args)
{
int low = 1;
int max = 100;
int randomNumber = random.nextInt(max - low + 1) + low;
Random rand = new Random();
return randomNumber;
String guessCount = 1;
int userNumber;
Scanner keyboard = new Scanner(System.in);
userNumber = keyboard.nextInt();
while (userNumber != randomNumber)
if (userNumber > randomNumber)
{
System.out.println("Too high, try again.");
}
else (userNumber < randomNumber)
{
System.out.println("Too low, guess again.");
}
else (userNumber == randomNumber)
{
System.out.println("It took you " + "of guesses.");
}
}
}
Aucun commentaire:
Enregistrer un commentaire