This is a simple Java-based game where a user competes against the computer in guessing numbers. The game is interactive and can be played in multiple rounds based on the user's choice.
-
The user decides how many rounds they want to play.
-
The computer picks a random number between 0 and 10.
-
The user guesses the number.
-
After each round:
- If the guess is correct, the user wins the round.
- If the guess is incorrect, the computer wins the round.
-
At the end of all rounds, the total scores are displayed, and the winner is announced:
- User Wins: If the user has more correct guesses.
- Computer Wins: If the computer has more wins.
- Random number generation using Java's
Math.random()
orRandom
class. - User input for guessing numbers and selecting the number of rounds.
- Score tracking for both user and computer.
- Final result based on total scores.
- Java Development Kit (JDK) 8 or higher.
- A command-line interface (CLI) or an IDE like Eclipse, IntelliJ IDEA, or VS Code to run the game.
- GuesserGame.java: The main file containing the game's logic.
- README.md: Instructions and details about the game.
- (Optional): Any additional resource files if used.
- Clone the repository:
git clone https://github.com/GauravWeb-Dev/java-programming-codes.git
Navigate to the project folder: bash
cd GuesserGame
Compile the Java file: bash javac GuesserGame.java
๐ฎ Sample Gameplay User decides to play 5 rounds. In Round 1, the computer selects 7. User guesses 5 (incorrect). Score: User: 0 | Computer: 1
In Round 2, the computer selects 3. User guesses 3 (correct). Score: User: 1 | Computer: 1
๐ค Contribution Contributions are welcome! Feel free to fork the repository, make changes, and create a pull request.
๐ง Contact For queries or suggestions:
Name: Gaurav Sardar Email: gauravsardar27@gmail.com LinkedIn: Gaurav Sardar