Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Guessing Game Objectives: Use if statements and a switch statement Use random number generators Use multiple do while loops Instructions: You are to design and

Guessing Game

Objectives:

Use if statements and a switch statement

Use random number generators

Use multiple do while loops

Instructions: You are to design and implement an application that plays the Hi-Lo guessing game with numbers. The program should start by picking a random number between 1 and 100 (inclusive). After that, it should repeatedly prompt the user to guess the number. On each guess, report to the user whether he or she guessed correct. If not, report whether the guess was too high, too low, out of range (less than 1 or greater than 100). The user can choose -1 during a game to quit the current game early. If they decide to do this, please display that as the result of his or her guess instead of to low/out of range. Continue accepting guesses until the user guesses correctly or chooses to quit. Make sure you count the number of guesses and report that value when the user guesses correctly or chooses to quit the game. If the user quits a game, just print that he or she has quit after so many guesses. At the end of each game (by quitting or a correct guess), prompt the user to determine whether he or she wants to play again. Continue playing games until the user chooses to stop. You can use -1 for this quit response. You can also use a letter like Y or N or even use a String like yes or no. Consider using two do loops to solve this problem although there are many other correct ways if you prefer another solution. Run: Be sure to test all possibilities in your test run: Run at least two continuous games, in which you prove the counter of guesses is resetting. Then run a game in which the user exits early with a -1. Make sure you still print the count of guesses; do not count the -1 as a guess. Then run a game to completion but check for each of the out of range cases. A guess that is (< -1, == 0, and finally > 100) Keep running games until user decides to quit the whole program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago