#include using namespace std; class calculator // Class calculator states { public://Public members of class calculator void addition(); void subtraction(); void multiplication(); void division(); private:// Private members of class calculator double sum; double product; double sub; double tot; }; int main () { calculator digits;//digits is the object given to the calculator char choice; do { cout << endl; cout << "Welcome to the CompE 46 Calculator, where magic happens with digits!" << endl; cout << "Choose A for Addition." << endl; cout << "Choose S for Subtraction." << endl; cout << "Choose M for Multiplication." << endl; cout << "Choose D for Division." << endl; cout << "Choose Q to quit this program." << endl; cout << "Please select an option." << endl; cin >> choice; switch (choice)//switch member { case 'A': case 'a': digits.addition(); break; case 'S': case 's': digits.subtraction(); break; case 'M': case 'm': digits.multiplication(); break; case 'D': case 'd': digits.division(); break; case 'Q': case 'q': cout << "Have a nice day!" << endl; exit(1); break; default: cout << "Your choice was INVALID. Select one of the choices listed." << endl; } } while (choice != 4); return 0; } void calculator::addition()//Definition for addition in calculator class { double a, b; //do //{ cout << "Welcome to the ADDITION SECTION!" << endl; cout << "Please enter a Number and press Enter." << endl; cin >> a; // cout << "Invalid choice. Restarting Program. Please type a number." << endl; //} while (a == 0); cout << "Select a number you want to add to the number entered in the previous step." << endl; cin >> b; cout << endl; sum = a + b; cout << a << " plus " << b << " equals " << sum << endl; } void calculator::subtraction()//Definition for subtraction in calculator class { double c, d; cout << "Welcome to the SUBTRACTION SECTION!" << endl; cout << "Please select a number and press Enter." << endl; cin >> c; cout << "Select a number you want to subtract to the number entered in the previous step." << endl; cin >> d; cout << endl; sub = c - d; cout << c << " minus " << d << " equals " << sub << endl; } void calculator::multiplication()//Definition for multiplication in calculator class { double e, f; cout << "Welcome to the MULTIPLICATION SECTION!" << endl; cout << "Please select a number and press Enter." << endl; cin >> e; cout << "Select a number you want to multiply to the number entered in the previous step." << endl; cin >> f; cout << endl; product = e * f; cout << e << " times " << f << " equals " << product << endl; } void calculator::division()//Definition for division in calculator class { double g, h; cout << "Welcome to the DIVISION SECTION!" << endl; cout << "Please select a number and press Enter." << endl; cin >> g; do { cout << "Select a number you want to divide to the number entered in the previous step." << endl; cout << "ZERO is not a valide choice." << endl; cin >> h; if (h !=0) if (h == 0) }while (h == 0); cout << endl; tot = g / h; cout << g << " divided by " << h << " equals " << tot << endl; }