Guest User

Untitled

a guest
Jan 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. double Num1;
  10. double Num2;
  11. int Operation;
  12. int Reply;
  13.  
  14. double Result;
  15. cout << " \t \t \t \t welcome to Calculator\t \t \t \t " << endl;
  16.  
  17. startingpoint:
  18.  
  19. //TAKE THE INPUT FROM USER //
  20.  
  21. cout << "please enter two numbers \n" << endl;
  22. cin >> Num1 >> Num2;
  23.  
  24. //CHECK THE VALIDATE OF NUMBERS//
  25.  
  26. if (cin.fail())
  27. {
  28.  
  29. cin.clear();
  30. cin.ignore(10000, '\n');
  31.  
  32. goto startingpoint;
  33.  
  34. }
  35.  
  36. // TAKE THE OPERATION FROM USER//
  37.  
  38. chooseOperation:
  39.  
  40. cout << "please enter 1 for + , 2 for - , 3 for * , 4 for / , 5 to enter other numbers" << endl;
  41. cin >> Operation;
  42. //RE ENTER THE TWO NUMBERS//
  43.  
  44. if (cin.fail())
  45. {
  46.  
  47. cout << "please select validate operation" << endl;
  48. cin.clear();
  49. cin.ignore(10000, '\n');
  50. goto chooseOperation;
  51.  
  52. }
  53. else if (Operation == 1)
  54. {
  55.  
  56. Result = Num1 + Num2;
  57.  
  58. }
  59.  
  60. else if (Operation == 2)
  61. {
  62. Result = Num1 - Num2;
  63. }
  64.  
  65. else if (Operation == 3)
  66. {
  67.  
  68. Result = Num1 * Num2;
  69.  
  70. }
  71.  
  72. else if (Operation == 4)
  73. {
  74. if (Num2 == 0)
  75. {
  76. cout << "Can't divide over zero \n" << endl;
  77.  
  78. goto chooseOperation;
  79.  
  80. }
  81.  
  82. else
  83. {
  84. Result = Num1 / Num2;
  85. }
  86.  
  87.  
  88. }
  89.  
  90. else if (Operation == 5)
  91. {
  92. goto startingpoint;
  93. }
  94.  
  95. //OUR OUTPUT//
  96.  
  97. cout << "The Result is " << Result << endl;
  98.  
  99. // MAKE OFFER FOR USER
  100.  
  101. cout << " if you want to calculate other two numbers enter zero" << endl;
  102. cin >> Reply;
  103. if (Reply == 0)
  104.  
  105. {
  106. goto startingpoint;
  107.  
  108.  
  109. }
  110. else {
  111.  
  112. cout << "Thank's for using our software \n";
  113. }
  114.  
  115. system("pause");
  116. }
Add Comment
Please, Sign In to add comment