Last active
February 27, 2026 19:50
-
-
Save YousufProjs-exe/4ac415c7f268c5b5bbc7790f73a15fcf to your computer and use it in GitHub Desktop.
A Guessing Number game verses Computer (limit 100 ; Customize when can "i="in source code). Required JDK with IDE or Built in Compiler.
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
| import java.util.Random; | |
| import java.util.Scanner; | |
| public class Game_3 | |
| { | |
| public static void main(String args[]) | |
| { | |
| System.out.println("Welcome"); | |
| Random rand = new Random(); | |
| Scanner in = new Scanner(System.in); | |
| int n = rand.nextInt(100); | |
| // limit can be changed by replacing "100" present above | |
| int guess = -1; | |
| while(guess != n) | |
| { | |
| System.out.println("Your try"); | |
| guess = in.nextInt(); | |
| if(guess > n) | |
| System.out.println("Too High"); | |
| if(guess < n) | |
| System.out.println("Too Low"); | |
| } | |
| in.close(); | |
| System.out.println("You won"); | |
| //System.out.println("Credit: 25061-CS-010"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment