Question: Extend the C++ math program below so it includes the following: -Gives instructions -Displays previous users name and score from file -Prompts for the current

Extend the C++ math program below so it includes the following:

-Gives instructions

-Displays previous users name and score from file

-Prompts for the current users name

-Provides a menu of math choices (e.g., +. -, *, /), plus exit

-Asks users how many questions they want to answer

-Asks user for highest number to use

-Displays appropriate math questions with random numbers

-Keeps track of right and wrong answers

-Provide at least 10 randomly chosen correct and incorrect answers for feedback

-Gives feedback on how many questions answered and percent right for that group

-Returns to menu for possible additional problems

-When exit chosen shows grand total statistics correct, attempted, and percent right

-Writes name and results to file

-When running again displays name and results of last person to use the program

-Break program into appropriate functions

-Write and use data validation functions in a private library of your creation that includes generic functions for getString, getInt, and getFloat.

#include "stdafx.h" #include #include #include using namespace std; int main() { //declare variables const int MAX_RANGE = 100; int randomNumber1, randomNumber2; double result; int choice; int answer; bool selection = true;

//continue loop till user quits do { unsigned seed = time(0); srand(seed); //generate random numbers randomNumber1 = 1 + rand() % MAX_RANGE; randomNumber2 = 1 + rand() % MAX_RANGE;

//menu cout << "----MENU---- " << "1. Addition " << "2. Subtraction " << "3. Multiplication " << "4. Division " << "5. QUIT "; cout << "Enter your choice (1/2/3/4/5)"; cin >> choice;

switch (choice) { case 1: cout << "Addition" << endl; cout << setw(5) << randomNumber1 << endl; cout << "+" << setw(3) << randomNumber2 << endl; cout << "----" << endl; result = randomNumber1 + randomNumber2; break; case 2: cout << "Subtraction" << endl; cout << setw(5) << randomNumber1 << endl; cout << "-" << setw(3) << randomNumber2; cout << "----" << endl; result = randomNumber1 - randomNumber2; break; case 3: cout << "Multiplication" << endl; cout << setw(5) << randomNumber1 << endl; cout << "*" << setw(3) << randomNumber2; cout << "----" << endl; result = randomNumber1 - randomNumber2; break; case 4: cout << "Division" << endl; cout << setw(5) << randomNumber1 << endl; cout << "/" << setw(3) << randomNumber2; cout << "----" << endl; result = randomNumber1 - randomNumber2; break; //Quit case 5: system("pause"); exit(0); default: cout << "Enter a choice from the menu (1/2/3/4/5)" << endl; selection = false; } if (selection) { cout << "Enter your answer."; cin >> answer; if (answer == result) cout << "Good Job! Your answer is correct!" << endl; } else { cout << "Sorry, your answer is wrong. Thecorrect answer is: " << setw(3) << result << endl; } selection = true; cout << endl; } while (selection); system("pause"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!