Hello, I am having a little problem with this program, I'm supposed to make a program to send out two random then pause the program to make the person solve and then have him press a key and the answer will show up in the program.
/*Write a program that can be used as a math tutor for a young student. The program
should display two random numbers to be added, such as
247 + 129 =
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 a key and the program will
display the correct solution:
int main()
{
double A, B, C;
unsigned seed = time(0);
srand(seed);
cout << "Hello, Welcome to Math Tutor 2.0 =D " << endl;
cout << "I will be helping you learn addition today, pay attention." << "\n\n";
cout << "I will display two random numbers, try and solve for the answer." << endl;
A = 1 + rand() % 350;
B = 1 + rand() % 350;
C = A + B;
cout << "\n";
cout << A << " + " << B << " = ";
cout << C << endl;
system("pause");
return 0;
}
This is what I have, the only problem is I dont know how to pause it then press a key to make the answer show up
/*Write a program that can be used as a math tutor for a young student. The program
should display two random numbers to be added, such as
247 + 129 =
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 a key and the program will
display the correct solution:
247 + 129 = 376 */
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main()
{
double A, B, C;
unsigned seed = time(0);
srand(seed);
cout << "Hello, Welcome to Math Tutor 2.0 =D " << endl;
cout << "I will be helping you learn addition today, pay attention." << "\n\n";
cout << "I will display two random numbers, try and solve for the answer." << endl;
A = 1 + rand() % 350;
B = 1 + rand() % 350;
C = A + B;
cout << "\n";
cout << A << " + " << B << " = " << endl;
system("pause");
cout << A << " + " << B << " = " << C << endl;
return 0;
}
or
/*Write a program that can be used as a math tutor for a young student. The program
should display two random numbers to be added, such as
247 + 129 =
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 a key and the program will
display the correct solution:
247 + 129 = 376 */
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main()
{
double A, B, C;
char next;
unsigned seed = time(0);
srand(seed);
cout << "Hello, Welcome to Math Tutor 2.0 =D " << endl;
cout << "I will be helping you learn addition today, pay attention." << "\n\n";
cout << "I will display two random numbers, try and solve for the answer." << endl;
A = 1 + rand() % 350;
B = 1 + rand() % 350;
C = A + B;
cout << "\n";
cout << A << " + " << B << " = " << endl;
cout << "Hit any key and then Enter to show the answer";
cin >> next;
cout << "" << endl;
cout << A << " + " << B << " = " << C << endl;
return 0;
}
The top one will just ask the user to press any key to continue. The bottom will need them to hit a key and hit Enter. I suppose the top is more what you're looking for.
@ecstasyaeternus, in the future please don't just post answers to peoples homework questions. That defeats the entire purpose of the assignment. The OP learns nothing from just copying and pasting code they don't understand, and if they have to explain it in class they're screwed. Also, the first of the solutions you provided isn't very efficient. System commands are almost always a poor way to go about solving a problem.