Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. class getNum
  7. {
  8.     public:
  9.         int a;
  10.         int b;
  11.         int c;
  12.         int add;
  13.         int sub;
  14.         int mult;
  15.         int div;
  16.         string quest;
  17.  
  18.         int ask()
  19.         {
  20.             cout << "Give me your first number.\n" << endl;
  21.             cin >> a;
  22.             cout << "Give me your second number.\n" << endl;
  23.             cin >> b;
  24.             cout << "what operation? (add, mult, sub, div)" << endl;
  25.             cin >> quest;
  26.             if(quest == 'add')
  27.             {
  28.                 c = a + b;
  29.             }
  30.             if(quest == 'sub')
  31.             {
  32.                 c = a - b;
  33.             }
  34.             if(quest == 'mult')
  35.             {
  36.                 c = a * b;
  37.             }
  38.             if(quest == 'div')
  39.             {
  40.                 c = a / b;
  41.             }
  42.             return c;
  43.  
  44.         }
  45.  
  46.  
  47. };
  48.  
  49. int main()
  50. {
  51.     getNum num;
  52.     num.ask();
  53.     cout << "The answer is " << c << endl;
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement