Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problems Task1 (10 points) Write a program that can be used as a math tutor for a young student. The program should display two random

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Problems Task1 (10 points) Write a program that can be used as a math tutor for a young student. The program should display two random numbers in the range of 1 through 500) to be added, such as: 357 + 123 The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press the [Enter] key and the program will display the correct solution: 357 + 123 480 Input [Enter) key. output The program will display two random numbers to be added first and prompt the user to enter any key and then display the sum of these two numbers. An Example of Test Run The output of your program might look like this: csci>a.out Press enter when you are ready to see the answer. 458 214 + 672 This solution will not be shown until the user enters a key. After the student presses the [Enter] key, you need to process it so that the program can continue. Since the Enter key is a whitespace, you should use either cin.ignore(); or cin.get (ch); to process the input. For more details about cin.get() and cin.ignore (), please read Chapter 3. Task2 (10 points) Modify the program in Taskl. The program should display two random numbers (in the range of 1 through 500) to be added, such as: 357 + 123 The program should then wait for the student to enter the answer. If the answer is correct, a message of congratulations is printed. If the answer is incorrect, a message should be printed showing the correct answer. Input A number for the solution output The program will display two random numbers to be added first and prompt the user to enter an answer for the sum of these two numbers and then display a message according to user's answer An Example of Test Runs An Example of Test Runs The output of your program might look like this: csci>a.out 339 + 259 Enter your answer: 588 this number is user's input Sorry. The correct answer is 598. csci>a.out 339 + 259 Enter your answer: 598 this number is user's input Congratulations! That's the correct answer. Task3 (30 points) Modify the program again so it displays a menu allowing the user to select an addition, subtraction, multiplication, or division problem. The final selection on the menu should let the user quit the program. After the user has finished the math problem, the program should display the menu again. The process is repeated until user chooses to quit the program. Input Validation: If the user selects an item not on the menu, display an error message and display the menu again. Additional requirements for the range of two random numbers to be generated In the case of subtraction, make sure the second number is smaller or equal to the first one using a while loop to validate. In the case of multiplication, make the first number in the range of 1 ~ 100 and the second number in the range of 19. single digit divisor ( 1 ~9) and a number that is a multiple of the divisor. For example, num = divisor * (rand(% 50 +1) Input An option from the displayed menu and a number for the solution output The program will first display a menu and prompt the user to enter a choice from the menu. The program then will display two random numbers to be computed and prompt the user to enter an answer for the result of these two numbers and display a message according to user's answer. This process will be repeated until the user's choice is to quit. An Example of Test Runs The output of your program might look like this: Math Tutor Menu 1. Addition problem 2. Subtraction problem 3. Multiplication problem 4. Division problem 5. Quit this program Enter your choice (1-5): 1 104 73 + 288 Sorry, the correct answer is 177. Math Tutor Menu 1. Addition problem 2. Subtraction problem 3. Multiplication problem 4. Division problem 5. Quit this program Enter your choice (1-5): 2 771 378 393 Congratulations! That's right. Math Tutor Menu 1. Addition problem 2. Subtraction problem 3. Multiplication problem 4. Division problem 5. Quit this program Enter your choice (1-5): 3 21 2 43 Sorry, the correct answer is 42. Math Tutor Menu 1. Addition problem 2. Subtraction problem 3. Multiplication problem 4. Division problem 5. Quit this program Enter your choice (1-5): 4 80 / 4 = 34 Sorry, the correct answer is 20. Math Tutor Menu 1. Addition problem 2. Subtraction problem 3. Multiplication problem 4. Division problem 5. Quit this program Enter your choice (1-5): 5 Thank you for using Math Tutor

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions