Balachander283 / NumberGuessingGame

The Number Guessing Game in Java generates a random number between 1-100 and prompts the user to guess it. It offers three levels of difficulty with different attempts allowed. The game uses java.util.Random and java.util.Scanner classes, and the number of attempts is predefined. Contributions are welcome to improve the game.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NumberGuessingGame

This is a simple number guessing game in Java that generates a random number between 1 and 100 and prompts the user to guess it. The game offers three levels of difficulty: easy, medium, and hard, each with a different number of attempts allowed.

Usage

To run the game, execute the NumberGuessingGame.java file. The program will prompt the user to select a difficulty level and then ask the user to input a number within the given range of that level. If the user's input matches the randomly generated number, the game is won. Otherwise, the program provides a hint for the user to guess again. The game ends either when the user correctly guesses the number, or when the maximum number of attempts is reached.

How to play

  • Run the program.
  • Select a difficulty level by entering a number between 1-3.
  • Enter a number between 1-100 to guess the randomly generated number.
  • Repeat step 3 until the number is guessed or until the maximum number of attempts is reached.
  • If the number is guessed, the game is won. Otherwise, the game is lost.

Implementation Details

The program uses the java.util.Random class to generate a random number between 1 and 100. It also uses the java.util.Scanner class to accept user input. The number of attempts allowed for each difficulty level is predefined.

Contributions

Contributions to this project are welcome. If you have an idea for an improvement, please submit a pull request.

License

This online reservation system is released under the MIT License, which means it is open-source and free to use, modify, and distribute. Please see the LICENSE file for more details. Note: This project may use third-party libraries that are subject to their own licenses. Please refer to the respective license files of those libraries for more information.

About

The Number Guessing Game in Java generates a random number between 1-100 and prompts the user to guess it. It offers three levels of difficulty with different attempts allowed. The game uses java.util.Random and java.util.Scanner classes, and the number of attempts is predefined. Contributions are welcome to improve the game.


Languages

Language:Java 100.0%