Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Anthony Rodriguez, DeAndre Rogers
- Date: Nov 6 19
- Class: ITSE 1302 - Intro to Computer Programming
- Instructor: Prof Welch
- The Math Tutor 2
- */
- #include <iostream> //cin, cout
- #include <iomanip> // setw(), fixed, showpoint, setprecision
- #include <string> // get string
- #include <cstdlib> // rand()
- #include <ctime> // get rand seed
- using namespace std;
- //function prototypes
- double addition(double numA,double numB);
- double subtraction(double numA,double numB);
- double multiplication(double numA,double numB);
- double division(double numA,double numB);
- int displayMenu();
- void add(double numA,double numB,double& numC);
- void sub(double numA,double numB,double& numC);
- void mult(double numA,double numB, double& numC);
- void div(double numA,double numB, double& numC);
- int compliment(int compA, int compB, int compC, int compD);
- int encourage(int encorA, int encorB, int encorC, int encorD);
- int main()
- {
- int choice;
- int numA;
- int numB;
- do
- {
- //Seed the random number generator
- seed = time(0);
- srand(seed);
- num_A = 1 + rand() % 12;
- num_B = 1 + rand() % 12;
- cout << "1. Add\n"
- << "2. Subtract\n"
- << "3. Multiply\n"
- << "4. Divide\n"
- << "5. Exit\n";
- cin >> choice;
- if (choice >= 1 && choice <= 5)
- {
- cout << "Enter the total to the following problem:\n";
- cout << " " << num_A << endl;
- switch (choice)
- {
- case 1: cout << " + ";
- total = num_A + num_B;
- break;
- case 2: total = num_A - num_B;
- cout << " - ";
- break;
- case 3: total = num_A * num_B;
- cout << " * ";
- break;
- case 4: total = num_A / num_B;
- cout << " / ";
- }
- cout << num_B << endl;
- cout << " ------\n ";
- cin >> Input;
- if (Input == total)
- cout << "\nGreat Job! " << Input << " is the correct answer.\n\n";
- else
- {
- cout << "\nWrong!\n";
- cout << "The correct answer is " << total << endl;
- }
- }
- if (choice < 1 || choice > 5)
- {
- cout << "Error 404: Please enter the number in range. (Between 1 & 5)\n";
- }
- if (choice == 5)
- cout << "Exiting! See ya around!\n\n";
- } while (choice != 5);
- cin.get();
- return 0;
- }
- //Menu function
- /*int displayMenu() {
- int choice;
- cout << "----------------"<< endl;
- cout << " Math Tutor Menu \n";
- cout << "----------------"<< endl;
- cout << "1. Addition" << endl;
- cout << "2. Subtraction " << endl;
- cout << "3. Multiplication" << endl;
- cout << "4. Division " << endl;
- cout << "5. Quit the program " <<endl << endl;
- cin >> choice;
- cout << endl;
- return choice;
- }
- */
- //addition
- void add(double numA,double numB,double& numC){
- numA = (rand() % (maxNum - minNum + 1)) + minNum;
- numB = (rand() % (maxNum - minNum + 1)) + minNum;
- numC = numA + numB;
- }
- double addition(double numA,double numB){
- double sum = 0;
- sum = numA + numB;
- return sum;
- }
- //subtraction
- void sub(double numA,double numB,double& numC){
- numA = (rand() % (maxNum - minNum + 1)) + minNum;
- numB = (rand() % (maxNum - minNum + 1)) + minNum;
- numC = numA - numB;
- }
- double subtraction(double numA,double numB){
- double total = 0;
- total = numA - numB;
- return total;
- }
- //multiplication
- void mult(double numA,double numB, double& numC){
- numA = (rand() % (maxNum - minNum + 1)) + minNum;
- numB = (rand() % (maxNum - minNum + 1)) + minNum;
- numC = numA * numB;
- }
- double multiplication(double numA,double numB){
- double total = 0;
- total = numA * numB;
- return total;
- }
- //division
- void div(double numA,double numB, double& numC){
- numA = (rand() % (maxNum - minNum + 1)) + minNum;
- numB = (rand() % (maxNum - minNum + 1)) + minNum;
- numC = numA / numB;
- }
- double division(double numA,double numB){
- double total = 0;
- total = numA / numB;
- return total;
- }
- //int compliment() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement