A fun and interactive Number Guessing Game built in Java. The user tries to guess a random number generated by the computer within a limited range and receives feedback (higher/lower) on guesses until the correct number is found.
This project demonstrates basic programming concepts such as loops, conditional logic, random numbers, and user input handling using the Scanner class.
The game works as follows :
- A random number is generated between 1 and 100.
- The player enters their guess.
- The program tells the player if their guess is too low, too high, or correct.
- The player keeps guessing until the number is found.
- The game ends when the correct number is guessed.
Number-Game/ βββ GuessTheNumber.java βββ README.md
- πΉ Java
- πΉ Scanner (for user input)
- πΉ Random number generation
- πΉ Loops and conditional logic
The program:
- Generates a random integer
- Takes user input from the console
- Compares input with the random number
- Provides helpful hints (βToo highβ, βToo lowβ)
- Continues until the correct guess
This simple game makes learning logic fun while demonstrating key fundamentals of programming.
git clone https://github.com/shreyadesai20042009/Number-Game.git
cd Number-Game
2οΈβ£ Compile the Java file
javac GuessTheNumber.java
3οΈβ£ Run the game
java GuessTheNumber
πΉ Gameplay Example
Welcome to Guess The Number!
Guess a number between 1 and 100:
> 58
Too low! Try again.
> 87
Too high! Try again.
> 75
Correct! π
Congratulations, you guessed the number in 4 attempts!
π Learning Outcomes
By completing this project, you will learn :
Handling user input
Using loops effectively
Applying random number generation
Conditional (if/else) logic
Basic console interactivity