Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. (20 marks) Write a C++ program that generates a math exercise for the user. The program should first ask for which operation an exercise

image text in transcribed

4. (20 marks) Write a C++ program that generates a math exercise for the user. The program should first ask for which operation an exercise should be generated. The Possibilities are addition ( + ), subtraction ( - ), multiplication (*), and division (1). After selecting an operation, the user should answer the following question: What is the maximum value for the input values of the exercise ? The answer to this question must be stored in a variable maximumValue. Next, the program should ask. Are negative values allowed in the exercise? The possible answers for the question are" Y " and "N". The program will then generate two random numbers. If the user allows negative values, the random numbers must be generated in the range from - maximum Value to + maximum Value ; if the user allows only positive values , the range is restricted from 0 to maximumValue. Moreover, if only positive numbers are allowed and subtraction was chosen , the second random value must be less than the first random value. Finally, the program will show the generated exercise, depending on the chosen operation and the numbers randomly generated, and ask the user for the correct solution. If the user solves the exercise correctly, the program will print out a congratulatory message

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

Step: 3

blur-text-image

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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions