Skip to content

Instantly share code, notes, and snippets.

@archigoodvin07
Last active October 3, 2021 14:42
Show Gist options
  • Save archigoodvin07/ca1aa8065cc8954e5fc566277c1de21c to your computer and use it in GitHub Desktop.
Save archigoodvin07/ca1aa8065cc8954e5fc566277c1de21c to your computer and use it in GitHub Desktop.
Game_One.java
// Game One
import java.util.Random;
import java.util.Scanner;
class GuessTheNumber {
public static void main(String[] args) {
Random random = new Random();
int randomValue = random.nextInt(100);
System.out.println("Hi. Try to guess the number from 0 to 100. Good luck");
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int yourNum = scanner.nextInt();
if (yourNum > randomValue) {
System.out.println("Sorry, but You are not guess.The number is lower. Please try again.");
}
else if (yourNum < randomValue) {
System.out.println("Sorry, but You don't guess.The number is bigger. Please try again.");
}
else {
System.out.println("Congrats. Your are winner!!!");
return;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment