Код: Выделить всё
import java.util.Scanner;
import java.util.Random;
public class Main {
static Scanner read = new Scanner(System.in);
public static void main(String[] args) {
int randomInt = new Random().nextInt(1000);
int userInput = -1;
System.out.println("I guessed a number\nYour turn: ");
while (randomInt != userInput) {
userInput = read.nextInt();
if (randomInt > userInput) {
System.out.println("Less than it");
} else if (randomInt < userInput){
System.out.println("More than that");
}
}
System.out.println("That's right!");
}
}
Подробнее здесь: https://stackoverflow.com/questions/753 ... om-package
Мобильная версия