
Daniel C.
asked 02/24/14how do i do this c++ program????????
The game stops when the player guesses 12 and 46 thus giving the random calculation 12 + 34 = 46.
3 Answers By Expert Tutors
John R. answered 01/21/24
California-Based Software Developer | Practical Coding Tutor
I would begin by writing a pretty simple function that would generate the random values and store them to global variables, A, B, and C. I would display one to the user (at random) along with its position in the equation used, along with the operator chosen, (be it addition, subtraction, or whatever else is allowed per the assignment requirements). Then I would begin to ask the user for guesses that I would then read via stdin and test against the two remaining, undisclosed, global variables. Check the users input against the values, use conditional statements to determine if one of the two values have been guessed, both would break from the while loop, and output the appropriate message, following the while loop I would have the print statement output the appropriate success message. The whole program could probably be written in about 100 lines of code, maybe a little more if you wanted to randomize the operators in the equation via enumerators for plus, minus, multiply, divide, power, root, or whatever else is allowed.
Terry T. answered 05/14/14
Anything IT related
Bivas B. answered 04/21/14
100% helpful and committed tutor working for your success.
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Anonymous A.
04/09/14