This week we looked at an example math program that would display the answer to a random math problem. Enhance this assignment to prompt the user to enter the solution to the displayed problem. After the user has entered their answer, the program should display a message indicating if the answer is correct or incorrect. If the answer is incorrect, it should display the correct answer. The division section should use Real data types instead of Integer data types. Keep track of how many correct/incorrect answers the user makes during the program and when they choose to exit, the program should display the percentage they got correct (# of correct / total # attempted).
HINT:
Keep in mind you will need to add 1 or more additional parameters
to the addition, subtraction, multiplication, and division methods
to support the ability to track the total attempted and total
correct. Also, be aware with the way Real numbers are stored in
memory, it will be nearly impossible for you to get a division
problem correct. You don't need to worry about adjusting for this
in your program, I just want to make you aware of this in case you
run into this issue while testing your program. Let me know if you
have questions or would like to discuss this further.
Example Output:
1) Addition
2) Subtraction
3) Multiplication
4) Division
5) Exit
Enter your selection:
1[Enter]
12 + 34 =
45 [Enter]
I’m sorry, the correct answer was 46
1) Addition
2) Subtraction
3) Multiplication
4) Division
5) Exit
Enter your selection:
2[Enter]
45 – 2 =
43[Enter]
Yes, that is the correct answer!
1) Addition
2) Subtraction
3) Multiplication
4) Division
5) Exit
Enter your selection:
5 [Enter]
Thanks for playing. You answered 1 out of 2 questions correct for a
score of 50%
IMPORTANT:
PROGRAM MUST BE RAPTOR IN INTERMEDIATE MODE.
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main(){
int ch;
double a,b,ans;
srand(time(NULL));
while(1){
cout << "1.Addition\n";
cout << "2.Subtraction\n";
cout << "3.Multipliction\n";
cout << "4.Divison\n";
cout << "5.Exit\n\n";
cout << "Enter your choice :";
cin >> ch;
a = rand()%100+1;
b = rand()%100+1;
if (ch == 5)
break;
if (ch == 1){
cout << a <<
" " << "+" << " " <<b << " " << "=
"<< endl;
cin >> ans;
if (ans == a+b)
cout
<< "Correct\n";
else
cout
<< "I am sorry the correct answer is " << a + b
<< endl;
}
if (ch == 2){
cout << a <<
" " << "-" << " " <<b << " " << "=
"<< endl;
cin >> ans;
if (ans == a-b)
cout
<< "Correct\n";
else
cout
<< "I am sorry the correct answer is " << a - b
<< endl;
}
if (ch == 3){
cout << a <<
" " << "*" << " " <<b << " " << "=
"<< endl;
cin >> ans;
if (ans == a*b)
cout
<< "Correct\n";
else
cout
<< "I am sorry the correct answer is " << a * b
<< endl;
}
if (ch == 4){
cout << a <<
" " << "/" << " " <<b << " " << "=
"<< endl;
cin >> ans;
if (ans == a/b)
cout
<< "Correct\n";
else
cout
<< "I am sorry the correct answer is " << a / b
<< endl;
}
}
return 0;
}
This week we looked at an example math program that would display the answer to a...
Create a web page that will help students practice math - Addition, Subtraction, Multiplication and Division. The page should generate and display a math problem using 2 random numbers from 1 to 12. Addition: [1 - 12] + [1 - 12] = [2 - 24]<-Calculated Subtraction: [2 - 24]<-Calculated - [1 - 12] = [1 - 12] Multiplication: [1 - 12] * [1 - 12] = [1 - 144]<-Calculated Division: [1 - 144]<-Calculated / [1 - 12] = [1 -...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
Write a MIPS math quiz program in MARS. The program should start with a friendly user greeting. From there, it should generate a random arithmetic problem. Your program will need to generate three random things: the first and second operand and the operator to use. Your program should generate random positive integers no greater than 20 for the operands. The possible operators are +, -, * and / (division). The user should be prompted for an answer to the problem....
Write a Python Program that displays repeatedly a menu as shown in the sample run below. The user will enter 1, 2, 3, 4 or 5 for choosing addition, substation, multiplication, division or exit respectively. Then the user will be asked to enter the two numbers and the result for the operation selected will be displayed. After an operation is finished and output is displayed the menu is redisplayed, you may choose another operation or enter 5 to exit the...
Math Problem Generator Your job will be to write a C++ program to teach math to school children. Your program will accomplish this by showing sets of math problems to the user and allowing them to enter an answer. The program should tell the user if they are correct and should continue providing additional questions. The program will keep track of correct and incorrect answers. The questions should use random numbers and should be simple enough math problems that someone...
Read description carefully. Needs to catch exceptions and still be
able to keep the program going on past the error. Program should
allow user to keep going until he or she quits
Math tutor) Write a program that displays a menu as shown in the sample run. You can enter 1, 2. 3, or 4 for choosing an addition. subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter...
Instructions Basically, you will modify the mathq program to make it satisfy a different set of requirements, and fix what is not working in it. Specifically, imagine that the client for whom we created the mathq program for would now like some changes. To be exact: Part 1: They want it to provide addition and subtraction problems as well as multiplication and division. They still want the choice to be random, as before, but now the problem is randomly multiplication,...
With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Your static methods should accept two integers and return an integer. Do...
RAPTOR PROGRAMMING Write a program which will receive two integer values as input. Then prompt the user to choose one of the following operations and produce an output with the selected operation. 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulo Division Example output with response: Please enter an input: 2 Please enter another input: 3 Please choose from the follow: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulo Division Output: 2 % 3 is 2.
A Simple Calculator Summary: Write a console program (character based) to do simple calculations (addition, subtraction, multiplication and division) of two numbers, using your understanding of Java. Description: You need to write a program that will display a menu when it is run. The menu gives five choices of operation: addition, subtraction, multiplication, division, and a last choice to exit the program. It then prompts the user to make a choice of the calculation they want to do. Once the...