#include using namespace std; class calculator { public: void addition(); void subtraction(); void multiplication(); void division(); private: double sum; double product; double sub; double tot; }; int main () { calculator digits; int choice; do { cout << endl; cout << "Welcome to the CompE 46 Calculator, where magic happens with digits!" << endl; cout << "Choose 1 for Addition." << endl; cout << "Choose 2 for Subtraction." << endl; cout << "Choose 3 for Multiplication." << endl; cout << "Choose 4 for Division." << endl; cout << "Choose 0 to quit this program." << endl; cin >> choice; switch (choice) { case 1: digits.addition(); break; case 2: digits.subtraction(); break; case 3: digits.multiplication(); break; case 4: digits.division(); break; case 0: exit(0); default: cout << "Your choice was INVALID. Select one of the choices listed." << endl; } } while (choice != 4); return 0; } void calculator::addition() { double a, b; cout << "Welcome to the ADDITION SECTION!" << endl; cout << "Please select a number and press Enter." << endl; cin >> a; 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() { 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() { 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() { double g, h; cout << "Welcome to the DIVISION SECTION!" << endl; cout << "Please select a number and press Enter." << endl; cin >> g; cout << "Select a number you want to divide to the number entered in the previous step." << endl; cin >> h; cout << endl; tot = g / h; cout << g << " divided by " << h << " equals " << tot << endl; }