Created
March 22, 2021 17:04
-
-
Save SirMefju/a7ab56dc81419e5906b13614020bf28e 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
int round = 1; | |
int min = 1; | |
int max = 20; | |
int number = (int) (Math.random() * (max - min + 1)) + min; | |
System.out.println("Chose number between 1 - 20"); | |
Scanner in = new Scanner(System.in); | |
boolean score = false; | |
while (!score) { | |
String a = in.nextLine(); | |
int chosen = Integer.parseInt(a); | |
if (chosen > number) { | |
System.out.println("Less"); | |
score = false; | |
round++; | |
} | |
if (chosen < number) { | |
System.out.println("more"); | |
score = false; | |
round++; | |
} | |
if (chosen == number) { | |
score = true; | |
} | |
} | |
System.out.println("Perfect, You guessed in round: " + round); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment