Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11. char op;
  12. int num1, num2;
  13. int sum;
  14. int product;
  15. int difference;
  16. int quotient;
  17. answer = //This doesnt equal anything.  It'll be an error.
  18.  
  19.  
  20. sum = num1 + num2;
  21. product = num1 * num2;
  22. difference = num1 - num2 ;
  23. quotient = num1 / num2;
  24.  
  25.  
  26. cout << "choose operation";
  27. cout << "+ addition" ;
  28. cout << "- subtract" ;
  29. cout << " * multiply" ;
  30. cout << " /  divide" ;
  31. //You are not cin -ing anything.  Theres no way for the user to input in an operator
  32.  
  33. //no default case.  What if the user enters *&^Y*YGYIUG as their operator?
  34. switch ( op )
  35. {
  36. case '+' :
  37.     cout << "Enter an integer";
  38.     cin >> num1;
  39.     cout << "Enter another integer";
  40.     cin >> num2;
  41.     cout << num1 + num2  ;
  42.     cout << sum;
  43.     cout << endl;
  44.     break;
  45.  
  46. case '-' :
  47.     cout << "Enter an integer" ;
  48.     cin >> num1 ;
  49.     cout << "Enter another integer";
  50.     cin >> num2 ;
  51.     cout << num1 - num2;
  52.     cout << difference;
  53.     cout << endl;
  54.     break;
  55.  
  56. case '*' :
  57.     cout << "Enter an integer" ;
  58.     cin >> num1 ;
  59.     cout << "Enter another integer";
  60.     cin >> num2 ;
  61.     cout << num1 * num2;
  62.     cout << product;
  63.     cout << endl;
  64.     break;
  65.  
  66.     case '/' :
  67.     cout << "Enter an integer" ;
  68.     cin >> num1 ;
  69.     cout << "Enter another integer";
  70.     cin >> num2 ;
  71.     cout << num1 / num2;
  72.     cout << quotient;
  73.     cout << endl;
  74.     break;
  75. }
  76.  
  77.  
  78.  
  79.     return 0;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement