Skip to content

Instantly share code, notes, and snippets.

@cxubrix
Created May 31, 2018 18:36
Show Gist options
  • Save cxubrix/c7fbf1153bfb3d39662956b20d6f59a1 to your computer and use it in GitHub Desktop.
Save cxubrix/c7fbf1153bfb3d39662956b20d6f59a1 to your computer and use it in GitHub Desktop.
import java.util.Random;
import java.util.Scanner;
public class Task02 {
public static void main(String[] args) {
Random rnd = new Random();
int randomInt = rnd.nextInt(11);
System.out.println("randomInt: " + randomInt);
Scanner sc = new Scanner(System.in);
boolean guessed = false;
System.out.println("Ievadi skaitli no 1 lidz 10");
do {
int sk = sc.nextInt();
guessed = sk == randomInt;
if (guessed) {
System.out.println(sk + " ok");
} else {
System.out.println("Wrong room number, please enter the number.");
}
} while (!guessed);
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment