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
- int displayMenu();
- void add(double numA,double numB,double& total);
- void sub(double numA,double numB,double& total);
- void mult(double numA,double numB, double& total);
- void div(double numA,double numB, double& total);
- 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;
- int answer;
- int total;
- int seed;
- do
- {
- //Seed the random number generator
- seed = time(0);
- srand(seed);
- numA = 1 + rand() % 12;
- numB = 1 + rand() % 12;
- 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;
- if (choice >= 1 && choice <= 5)
- {
- cout << "Enter the total to the following problem:\n";
- cout << " " << numA << endl;
- switch (choice)
- {
- case 1: void add();
- 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 (answer == total)
- cout << answer;
- 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;
- }
- //addition
- void add(){
- int numA = 1 + rand() % 12;
- int numB = 1 + rand() % 12;
- cout << " + ";
- total = numA + numB;
- cout << numB << endl;
- cout << " ------\n ";
- cin >> ans;
- }
- /*
- 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