A simple Java console-based game where the player has to guess a randomly generated number between 1 and 100. The game provides feedback such as "Too High" or "Too Low" until the correct number is guessed.
Random number generation using java.util.Random
User input via the console (Scanner)
Hint-based gameplay ("Too high", "Too low")
Tracks number of attempts
Simple and beginner-friendly code
Java (Core)
Console I/O
-
Clone the repo or download the .java file
-
Compile the code:
javac GuessNum.java
- Run the game:
java GuessNum
Guess the number between 1 and 100 Enter Your Guess Number: 50 Too high! Enter Your Guess Number:30 Too low! Enter Your Guess Number: 40 Correct! You guessed it in 3 attempts.
Java beginners Learning conditionals, loops, random numbers Small CLI-based game demos
Loops and Conditional Statements Random number generation Console Input/Output Basic game logic
HARSH SHRIVASTAVA
Linkedin: https://www.linkedin.com/in/harsh-shrivastava-9508032a5/