Skip to content

Java-based number guessing game where the user competes against the computer. The user decides how many rounds to play, and in each round, the computer picks a random number between 0 and 10. The user tries to guess it, and at the end, the game displays the total wins for both the user and the computer. โž•

Notifications You must be signed in to change notification settings

GauravWeb-Dev/JavaGuesserGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Guesser Game

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.


๐Ÿš€ How to Play

  1. The user decides how many rounds they want to play.

  2. The computer picks a random number between 0 and 10.

  3. The user guesses the number.

  4. After each round:

    • If the guess is correct, the user wins the round.
    • If the guess is incorrect, the computer wins the round.
  5. 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.

๐Ÿ›  Features

  • Random number generation using Java's Math.random() or Random 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.

๐Ÿ“ฆ Requirements

  • 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.

๐Ÿ“‚ File Structure

  • 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.

๐Ÿ”ง How to Run the Game

  1. 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

Run the game: bash java GuesserGame

๐ŸŽฎ 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

Final Scores after 5 rounds: User: 3 | Computer: 2. Result: User Wins! ๐ŸŽ‰

๐Ÿค 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

About

Java-based number guessing game where the user competes against the computer. The user decides how many rounds to play, and in each round, the computer picks a random number between 0 and 10. The user tries to guess it, and at the end, the game displays the total wins for both the user and the computer. โž•

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages