A fun little project in Java where the computer picks a random number between 1 and 100 and you have to guess it. Simple, interactive, and a perfect beginner-friendly game!
- 🎯 Computer randomly generates a number between 1–100
- ⌨️ Accepts user guesses and gives hints (Too high / Too low)
- 🔁 Unlimited attempts until you guess correctly
- 🎉 Congratulates you with total attempts taken
- 🚪 Exit gracefully with
Ctrl+D
(Linux/macOS) orCtrl+Z
(Windows)
javac Number_Guessing_Game.java
Welcome to the Number Guessing Game!
I'm thinking of a number between 1 and 100. Try to guess it!
Press Ctrl+D (Unix/macOS) or Ctrl+Z (Windows) then Enter to exit.
Enter your guess: 50
Too low! Try again.
Enter your guess: 75
Too high! Try again.
Enter your guess: 63
🎉 Congratulations! You guessed the number in 3 tries.
Thanks for playing!
-
Language: Java 11+
-
Type: CLI (Command-Line Interface)
-
Libraries: None (only Scanner & Random)
Want to improve this little game? Fork the repo and submit a PR:
git checkout -b feature/new-idea
git commit -m "Add difficulty levels"
git push origin feature/new-idea
This project is open-source and free to use...
💡 “Every wrong guess brings you closer to the right one!”