This assignment asks you to implement a guessing game as a C++ program. For this you...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This assignment asks you to implement a guessing game as a C++ program. For this you need to familiarize yourself with variables, ifs (nested and multiple ifs), random numbers, and loops. The program should do the following: • Print a welcome message • Repeat the following until the game is over indicated by user entering Q' or 'q'. o Select a random number between 1 and 20. o Ask the user to input a number between 1 and 20. o Check if the user input is equal to the generated random number. • If they are equal then the user has won. Print appropriate message. • If they are not equal then give the user a hint as to whether the user's entered number is greater or less than the random number and provide two more turns to the user giving the hint at each turn. (Total number of tries at guessing the generated random number is three (3)) Below is a screenshot of a working program: Scenario 1 A number has been randomly generated between 1-20 inclusive....Guess the number: 15 You have to go higher. You have 2 attempt (s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 17 You have to go lower. You have 1 attempt(s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 16 CONGRATULATIONS... You win :) Enter 'Y' to play the guessing game or 'Q' to quit This assignment asks you to implement a guessing game as a C++ program. For this you need to familiarize yourself with variables, ifs (nested and multiple ifs), random numbers, and loops. The program should do the following: • Print a welcome message • Repeat the following until the game is over indicated by user entering Q' or 'q'. o Select a random number between 1 and 20. o Ask the user to input a number between 1 and 20. o Check if the user input is equal to the generated random number. • If they are equal then the user has won. Print appropriate message. • If they are not equal then give the user a hint as to whether the user's entered number is greater or less than the random number and provide two more turns to the user giving the hint at each turn. (Total number of tries at guessing the generated random number is three (3)) Below is a screenshot of a working program: Scenario 1 A number has been randomly generated between 1-20 inclusive....Guess the number: 15 You have to go higher. You have 2 attempt (s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 17 You have to go lower. You have 1 attempt(s) left A number has been randomly generated between 1-20 inclusive...Guess the number: 16 CONGRATULATIONS... You win :) Enter 'Y' to play the guessing game or 'Q' to quit
Expert Answer:
Answer rating: 100% (QA)
code include include using namespace std int main char chY fo... View the full answer
Related Book For
Managerial economics applications strategy and tactics
ISBN: 978-1439079232
12th Edition
Authors: James r. mcguigan, R. Charles Moyer, frederick h. deb harris
Posted Date:
Students also viewed these computer engineering questions
-
The Managing Director, Tom Copeland has asked you to implement a process to monitor expenditure and income. He has asked you to prepare a spreadsheet to capture and compare actual income and...
-
Your boss has asked you to implement a new rotating work schedule that requires employees to work different schedules each week. Your boss would like to know how other companies in the area have...
-
Specific Electric Co. asked you to implement a pay-for- performance incentive contract for its new CEO. Using your deeper knowledge of the principal-agent problem, try it again.
-
Question 4: What is meant by statistical versus nonstatistical and probabilistic versus nonprobabilistic sample selection?
-
Lucia graduated this year with an accounting degree from Eastern Connecticut State University. She has received job offers from an accounting firm, an insurance company, and an airline. She cannot...
-
An electronic device, in the form of a disk 20 mm in diameter, dissipates 100 W when mounted flush on a large aluminum alloy (2024) block whose temperature is maintained at 27C. The mounting...
-
Dirk Coles checkbook lists the following: Dirk Coles September bank statement shows the following: Requirements 1. Prepare Dirk Coles bank reconciliation on September 30, 2010. How much cash does...
-
On October 1, the Business Students' Society (BSS) placed an order for 100 golf shirts at a unit cost of $20, under terms 2/10, n/30. The order was received on October 10, but 20 golf shirts had been...
-
Evaluate the integral. (Use C for the constant of integration.) 6 6 tanx dx Submit Answer
-
Callaway Golf Co. leases telecommunications equipment. Assume the following data for equipment leased from Photon Company. The lease term is 5 years and requires equal rental payments of $31,000 at...
-
What is an operating system? List the typical functions of operating systems.
-
Descriptive Writing Sample As you read the following example of descriptive writing, please do the following: 1. Highlight, in bil, the thesis statement (main idea) of the text. 2. Highlight, in...
-
1. Describe each of the five assumptions (or more, since it's better!) required for an instrumental variable's analysis. 2. Label the three assumptions represented in the diagram below. ZD Y X 3. Why...
-
1. Compare the values calculated to each of the market prices for the top twenty stock picks. Are the calculations close approximations of the market prices? Why do you think there are differences? ...
-
Atler Engineering Company is considering the replacement of one of its existing fabrication machines by a new machine, which is expected to cost Rs 1,650,000. The existing machine has a book value of...
-
What is produced by the following: String str = "March Madness"; int x = str.length(); System.out.println(x);
-
A particle of rest energy 700 MeV decays in its rest frame into two identical particles of rest energy 250 MeV. What are the kinetic energies (in MeV), momenta (in MeV/c), and velocities(in units of...
-
Imagine that your best friend knows you are taking a psychology course and wonders what psychology is all about. How would you define psychology for your friend? Write an essay on the discipline of...
-
An aircraft with 100 seats serves passengers through two types of fares: full ($550) and discount ($250). Extra passengers have $50 marginal cost. Demand for discount tickets is unlimited, while...
-
Discuss the problems of aircraft noise around an airport from an externality perspective and propose a possible solution if (a) Housing existed in the airport area before the airport was built and...
-
The Ajax Corporation has the following set of projects available to it: *Note: All projects have equal risk. Ajax can raise funds with the following marginal costs: First $250 million..............
-
Discuss the physical meaning of the small-signal circuit parameter \(r_{o}\).
-
Discuss, using the concept of a load line, how a simple common-source circuit can amplify a time-varying signal.
-
Sketch a simple source-follower amplifier circuit and discuss the general ac circuit characteristics (voltage gain and output resistance).
Study smarter with the SolutionInn App