Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class getNum
- {
- public:
- int a;
- int b;
- int c;
- int add;
- int sub;
- int mult;
- int div;
- string quest;
- int ask()
- {
- cout << "Give me your first number.\n" << endl;
- cin >> a;
- cout << "Give me your second number.\n" << endl;
- cin >> b;
- cout << "what operation? (add, mult, sub, div)" << endl;
- cin >> quest;
- if(quest == 'add')
- {
- c = a + b;
- }
- if(quest == 'sub')
- {
- c = a - b;
- }
- if(quest == 'mult')
- {
- c = a * b;
- }
- if(quest == 'div')
- {
- c = a / b;
- }
- return c;
- }
- };
- int main()
- {
- getNum num;
- num.ask();
- cout << "The answer is " << c << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement