Skip to content

heg-web/guessinggame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guessing Game

This fun and easy project "Guess the Number" is a short Java project that allows the user to guess the number generated by the computer and involves the following steps:

  1. The system generates a random secret number from a given range, say 1 to 100.
  2. The user is prompted to enter their guess number in a displayed dialogue box.
  3. The computer then tells if the entered number matches or is higher/lower than the secret number.
  4. The game continues until the user guesses the secret number.

Compile and Run

Inside the src folder

Compile

javac GuessingGame.java

Run

java GuessingGame

Improvement Ideas

You can incorporate further details:

  • Improving the code syntax, for example:
    • Add error handling for non-integer user input.
    • Use constants for the minimum and maximum values instead of hardcoding them.
    • Use a do-while loop
    • Add comments to explain the purpose of the code and each method.
  • Limiting the number of attempts.
  • Playing another round.
  • Choose a difficulty level
  • Displaying score.
  • Giving points based on the number of attempts.
  • Your ideas?

Source: https://hackr.io/blog/java-projects

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages