Created
May 31, 2018 18:36
-
-
Save cxubrix/c7fbf1153bfb3d39662956b20d6f59a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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