Giter Club home page Giter Club logo

guess-the-number-game's Introduction

Guess-the-Number-Game

GitHub GitHub top language GitHub last commit ViewCount


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
|

           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~~~πŸ™πŸ˜~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

guess-the-number-game's People

Contributors

geekguruu avatar hegdepavankumar avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

geekguruu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.