+ 1

Math Tutor Problem

//C++ Program Math Problem //Gabriel Reyes January 11, 2022 CIS-5 //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 //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 should display the correct solution. #include<iostream> using namespace std; int main() { //declared variables float Num1 = 0; float Num2 = 0; float Answer = 0; //input section cout << "Hello! Today we will be doing some basic Math\n\n"; cout << "Please enter One Random Number!: "; cin >> Num1; cout << endl; cout << "Please enter a Second Random Number!: "; cin >> Num2; cout << endl; Answer = Num1 + Num2; cout << "Solve your problem on Paper, When you are ready, enter any button! "; cout << endl; system("pause"); cout << "Your Total number is: "; Answer; cout << endl; cout << "Thank you for your time! Goodbye!"; return 0; } Hello I am trying to have the user type in two random numbers to give a total but when I after i type in my two random numbers it leaves it blank when it is suppose to add up, any help on this? and any suggestions on how I can format this to be much cleaner? Thank you!

12th Jan 2022, 7:55 AM
Gabriel Reyes
4 ответов
+ 4
I haven't checked your code. But if it works accordingly, then it should wait until a key is pressed before it displays the calculation result right?
12th Jan 2022, 8:17 AM
Ipang
+ 1
remove system("pause"); The cout would looks like cout << "Your Total number is: " << Answer << endl; and check others cleaner? 1. Easy way, search c++ formatter beautifier, and rewrite your code as it does. 2. https://google.github.io/styleguide/cppguide.html
12th Jan 2022, 8:14 AM
FanYu
FanYu - avatar
+ 1
Everything works accordingly except it is not showing the total for the two random numbers you type to add up, it just leaves it blank
12th Jan 2022, 8:25 AM
Gabriel Reyes
+ 1
Follow 𝓕𝓛𝓨 suggestion, the line printing the <Answer> wasn't quite right 👍
12th Jan 2022, 10:54 AM
Ipang