Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hegdepavankumar/guess-the-number-game

Guess the Number Game using Java(OOPs Edition) ,Guess the number play with the Numbers....Have a Fun!..
https://github.com/hegdepavankumar/guess-the-number-game

constructor fun game guess-the-number java javagame learnbydoing oops-in-java

Last synced: about 2 months ago
JSON representation

Guess the Number Game using Java(OOPs Edition) ,Guess the number play with the Numbers....Have a Fun!..

Awesome Lists containing this project

README

        

# Guess-the-Number-Game

![GitHub](https://img.shields.io/github/license/hegdepavankumar/Guess-the-Number-Game?style=flat)
![GitHub top language](https://img.shields.io/github/languages/top/hegdepavankumar/Guess-the-Number-Game?style=flat)
![GitHub last commit](https://img.shields.io/github/last-commit/hegdepavankumar/Guess-the-Number-Game?style=flat)
![ViewCount](https://views.whatilearened.today/views/github/hegdepavankumar/Guess-the-Number-Game.svg?cache=remove)


Guess the Number Game using Java(OOPs Edition), Guess the number play with the Computer...Have a Fun!..

The task is to write a Java program in which a user will get K trials to guess a randomly generated number. Below are the rules of the game:

If the guessed number is bigger than the actual number, the program will respond with the message that the guessed number is higher than the actual number.
If the guessed number is smaller than the actual number, the program will respond with the message that the guessed number is lower than the actual number.
If the guessed number is equal to the actual number or if the K trials are exhausted, the program will end with a suitable message.

## Approach: Below are the steps:

The approach is to generate a random number using Math. random() method in Java.
Now using a loop, take K input from the user, and for each input print whether the number is smaller or larger than the actual number.
If within K trials the user guessed the number correctly, print that the user won.
Else print that he was not able to guess and then print the actual number.


## Algorithm for Number guessing game

Step 1: Create three variables attempt, userGuessNumber, and secretNumber, and initialize them.
Step 2: Generate a random number and assign it to a secret number.
Step 3: Start a loop and take user input.
Step 4: Validate user input and match with the secretNumber.
Step 5: If userGuessNumber is greater than or less than the secretNumber then print a message to the user.
Step 6: If userGuessNumber is equal to the secretNumber, then the user wins and exits the game.
Step 7: If several attempts exceed the limit, exit the game.
Step 8:Repeat from Step 3.

## Note
The GUI version of this game is Coming Soon ...Stay tuned!.

## Creator [πŸ”](# Guess-the-Number-Game)

(https://github.com/hegdepavankumar). This Project is Created by:-

| [
@hegdepavankumar](https://github.com/hegdepavankumar) |

```
Hey Everyone Please give me a star .. and Follow me for more amazing project ideas and Updates⭐ and don't forget to fork the repo....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thank you~~~πŸ™πŸ˜~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~