Last active
October 3, 2021 14:42
-
-
Save archigoodvin07/ca1aa8065cc8954e5fc566277c1de21c to your computer and use it in GitHub Desktop.
Game_One.java
This file contains hidden or 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
// 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