57.3k views
0 votes
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/She can press a key and the program will display the correct solution: 357 + 123 = 480?

User Xantrus
by
6.5k points

1 Answer

4 votes

Answer:

Code:

//Needed Libraries

#include <iostream>

#include <iomanip>

#include <cstdlib>

#include <ctime>

//starting the program

using namespace std;

int main()

{

//Creating the variables needed

double X,Y,Z;

//command for generating random number every time the program runs.

//without it the program default value will be srand(1).

srand(time(0));

// printing the lines to show user what to do.

cout << "Hello, Welcome to Math's Tutor " << endl;

cout << "I will be helping you learn addition today." << "\\\\";

cout << "I will display two random numbers, Solve for the answer." << endl;

//doing the needed calculations and putting the sum in Z

X = 1 + rand() % 500;

Y = 1 + rand() % 500;

Z = A + B;

//printing the value for user to solve

cout << "\\";

cout << X << " + " << Y << " = " << endl;

// pausing the system for user to solve the problem and press any key

system("pause");

//showing the answer to the problem

cout << X << " + " << Y << " = " << Z << endl;

return 0;

}

Step-by-step explanation:

the above program will print some lines for showing user what to do and then displaying the numbers for user to solve for the answer and then let the user to see the answer when the user press any key.

the random number shown will be between 1 to 500. if the user want to change the range so

X = 1 + rand() % 500;

Y = 1 + rand() % 500;

Put the number for your range instead of 500. It can be 1000, 5000, etc it will increase the range if you want to decrease it then pu a lower number then 500 instead.

After it will allow the user to solve the problem. then show the answer when user press any key.

User Michael Abeln
by
5.8k points