Advertisement
dangerscout

Untitled

Aug 24th, 2019
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. int whattodo, result;
  10. float num_1, num_2, res;
  11. cout << "Enter first number:" << endl;
  12. cin >> num_1;
  13. cout << "Enter second number:" << endl;
  14. cin >> num_2;
  15. cout << "Enter what to do:" << endl;
  16. cout << "1 - +" << endl;
  17. cout << "2 - -" << endl;
  18. cout << "3 - *" << endl;
  19. cout << "4 - /" << endl;
  20. cout << "5 - %" << endl;
  21. cout << "Your choice is:" << endl;
  22. cin >> whattodo;
  23.  
  24. if (whattodo == 1) {
  25. res = num_1 + num_2;
  26. cout << "Solution is:" << endl;
  27. cout << num_1 << "+" << num_2 << "=" << res << endl;
  28. }
  29.  
  30. if (whattodo == 2) {
  31. res = num_1 - num_2;
  32. cout << "Solution is:" << endl;
  33. cout << num_1 << "-" << num_2 << "=" << res << endl;
  34. }
  35.  
  36. if (whattodo == 3) {
  37. res = num_1 * num_2;
  38. cout << "Solution is:" << endl;
  39. cout << num_1 << "*" << num_2 << "=" << res << endl;
  40. }
  41.  
  42. if (whattodo == 4) {
  43. res = num_1 / num_2;
  44. cout << "Solution is:" << endl;
  45. cout << num_1 << "/" << num_2 << "=" << res << endl;
  46. }
  47.  
  48. if (whattodo == 5) {
  49. result = (int)num_1 % (int)num_2;
  50. cout << "Solution is:" << endl;
  51. cout << num_1 << "%" << num_2 << "=" << result << endl;
  52. }
  53.  
  54. if (whattodo != 1 || whattodo != 2 || whattodo != 3 || whattodo != 4 || whattodo != 5)
  55. {
  56. cout << "Incorrect choice. Try again." << endl;
  57. }
  58.  
  59. system("pause");
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement