Guest User

Untitled

a guest
Dec 14th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. calc:
  9. int a;
  10. int b;
  11. int c;
  12. int d;
  13. int e;
  14. int f;
  15. int g;
  16. int h;
  17. int i;
  18. int j;
  19. int total;
  20. cout << "This is a calculator. Press 1. for plus, 2. for minus 3. for multiplication 4. for division." << endl;
  21. cin >> a;
  22. if (a == 1)
  23. {
  24. cout << "You chose plus. Tell me first number." << endl;
  25. cin >> b;
  26. cout << "Now tell me another number." << endl;
  27. cin >> c;
  28.  
  29. total = b + c;
  30.  
  31. cout << "Result: " << endl;
  32. cout << total << endl;
  33. cout << "-------------------------------------------------------------------------------------------" << endl;
  34. cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
  35. cin >> j;
  36. if (j == 1)
  37. {
  38. goto calc;
  39. }
  40. if (j == 2)
  41. {
  42. exit(0);
  43. }
  44. else
  45. {
  46. cout << "Press 1 or 2." << endl;
  47. }
  48. }
  49. if (a == 2)
  50. {
  51. cout << "You chose minus. Tell me first number." << endl;
  52. cin >> d;
  53. cout << "Now tell me another number." << endl;
  54. cin >> e;
  55.  
  56. total = d - e;
  57.  
  58. cout << "Result: " << endl;
  59. cout << total << endl;
  60. cout << "-------------------------------------------------------------------------------------------" << endl;
  61. cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
  62. cin >> j;
  63. if (j == 1)
  64. {
  65. goto calc;
  66. }
  67. if (j == 2)
  68. {
  69. exit(0);
  70. }
  71. else
  72. {
  73. cout << "Press 1 or 2." << endl;
  74. }
  75. }
  76. if (a == 3)
  77. {
  78. cout << "You chose multiplication. Tell me first number." << endl;
  79. cin >> f;
  80. cout << "Now tell me another number." << endl;
  81. cin >> g;
  82.  
  83. total = f * g;
  84.  
  85. cout << "Result: " << endl;
  86. cout << total << endl;
  87. cout << "-------------------------------------------------------------------------------------------" << endl;
  88. cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
  89. cin >> j;
  90. if (j == 1)
  91. {
  92. goto calc;
  93. }
  94. if (j == 2)
  95. {
  96. exit(0);
  97. }
  98. else
  99. {
  100. cout << "Press 1 or 2." << endl;
  101. }
  102. }
  103. if (a == 4)
  104. {
  105. cout << "You chose division. Tell me first number." << endl;
  106. cin >> h;
  107. cout << "Now tell me another number." << endl;
  108. cin >> i;
  109.  
  110. total = h / i;
  111.  
  112. cout << "Result: " << endl;
  113. cout << total << endl;
  114. cout << "-------------------------------------------------------------------------------------------" << endl;
  115. cout << "If you still want to count, press 1, if you want to exit, press 2." << endl;
  116. cin >> j;
  117. if (j == 1)
  118. {
  119. goto calc;
  120. }
  121. if (j == 2)
  122. {
  123. exit(0);
  124. }
  125. else
  126. {
  127. cout << "Press 1 or 2." << endl;
  128. }
  129. }
  130. else
  131. {
  132. cout << "Press one of the numbers to count." << endl;
  133. cout << "--------------------------------------------------------------------------------------------" << endl;
  134. }
  135. return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment