Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class myAdd
- {
- public:
- int myAddi(int num1, int num2);
- };
- int myAdd::myAddi(int num1, int num2)
- {
- int ans;
- ans = num1 + num2;
- cout << " " << num1 << " + " << num2 << " = " << ans;
- return 0;
- }
- class mySub
- {
- public:
- int mySubd(int num1, int num2);
- };
- int mySub::mySubd(int num1, int num2)
- {
- int ans;
- ans = num1 - num2;
- cout << " " << num1 << " - " << num2 << " = " << ans;
- return 0;
- }
- class myMul
- {
- public:
- int myMult(int num1, int num2);
- };
- int myMul::myMult(int num1, int num2)
- {
- int ans;
- ans = num1 * num2;
- cout << " " << num1 << " * " << num2 << " = " << ans;
- return 0;
- }
- class myDiv
- {
- public:
- int myDivi(int num1, int num2);
- };
- int myDiv::myDivi(int num1, int num2)
- {
- int ans;
- ans = num1 / num2;
- cout << " " << num1 << " / " << num2 << " = " << ans;
- return 0;
- }
- class myMod
- {
- public:
- int myModu(int num1, int num2);
- };
- int myMod::myModu(int num1, int num2)
- {
- cout << "- Quotient: " << num1 << " ÷ " << num2 << " = " << num1 / num2 << endl;
- cout << "- Remainder: " << num1 << " % " << num2 << " = " << num1 % num2;
- return 0;
- }
- int main()
- {
- int ans = 0;
- int num1, num2;
- char sel;
- string dw;
- do
- {
- system("cls");
- cout << "------------------------------" << endl;
- cout << "---- Ry's Calculator ----" << endl;
- cout << "------------------------------" << endl;
- cout << "- Enter first number: ";
- cin >> num1;
- cout << "- Enter second number: ";
- cin >> num2;
- cout << "------------------------------" << endl;
- cout << " Choose operation:\n-" << endl;
- cout << "- 1. + Addition" << endl;
- cout << "- 2. - Subtraction" << endl;
- cout << "- 3. * Multiplication" << endl;
- cout << "- 4. / Division" << endl;
- cout << "- 5. % Modulo" << endl;
- cout << "-\n Selected Operation: ";
- cin >> sel;
- cout << "------------------------------" << endl;
- if (sel == '1' || sel == '+')
- {
- myAdd myOb1;
- myOb1.myAddi(num1, num2);
- }
- if (sel == '2' || sel == '-')
- {
- mySub myOb2;
- myOb2.mySubd(num1, num2);
- }
- if (sel == '3' || sel == '*')
- {
- myMul myOb3;
- myOb3.myMult(num1, num2);
- }
- if (sel == '4' || sel == '/')
- {
- myDiv myOb4;
- myOb4.myDivi(num1, num2);
- }
- if (sel == '5' || sel == '%')
- {
- myMod myOb5;
- myOb5.myModu(num1, num2);
- }
- cout << "\n------------------------------" << endl;
- cout << "- Do you want to use the\n- calculator again??:: ";
- cin >> dw;
- } while (dw.compare("Y") == 0 || dw.compare("y") == 0 || dw.compare("yes") == 0 || dw.compare("Yes") || dw.compare("YES") == 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement