Hello i am trying to make a java file so when i run it will generate a random number between 1 and 10 and when the awnser it will tell me if its to high to low or good but what i have tried dit not work
public static void main(String[] args) {
Random rand = new Random();
int test = rand.nextInt(10) + 1;
String input;
Scanner user_input = new Scanner( System.in );
System.out.println("Wat is het random nummer");
input = user_input.next();
if(user_input.nextInt() > test) {
System.out.println("Te hoog");
} else if (user_input.nextInt() < test) {
System.out.println("te laag");
} else {
System.out.println("Goedzo!");
}
}
Aucun commentaire:
Enregistrer un commentaire