Guest User

Untitled

a guest
Jun 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6.  
  7. double Addition(double Num1, double Num2)
  8. {
  9. return Num1 + Num2;
  10. }
  11.  
  12. double Subtraction(double Num1, double Num2)
  13. {
  14. return Num1 - Num2;
  15. }
  16.  
  17. double Multiplication(double Num1, double Num2)
  18. {
  19. return Num1 * Num2;
  20. }
  21.  
  22. double Division(double Num1, double Num2)
  23. {
  24. return Num1 / Num2;
  25. }
  26.  
  27. int main()
  28. {
  29. double Number1;
  30. double Number2;
  31. int operation;
  32. char systempause;
  33.  
  34. cout << "\n Welcome to this easy to use text-based calculator. \n" << endl;
  35. cout << "\n What would you like to do? \n" << endl;
  36. cout << "\n Press 1 for Addition. \n Press 2 for Subtraction. \n Press 3 for Multiplication. \n Press 4 for Division. \n" << endl;
  37. cin >> operation;
  38.  
  39. if (operation==1)
  40. {
  41. cout << "\n You have chosen addition. Please input the first number. \n" << endl;
  42. cin >> Number1;
  43. cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
  44. cin >> Number2;
  45. cout << "\n The answer is " << Addition(Number1, Number2) << endl;
  46. }
  47. else
  48. {
  49. if (operation==2)
  50. {
  51. cout << "\n You have chosen subtraction. Please input the first number. \n" << endl;
  52. cin >> Number1;
  53. cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
  54. cin >> Number2;
  55. cout << "\n The answer is " << Subtraction(Number1, Number2) << endl;
  56. }
  57. else
  58. {
  59. if (operation==3)
  60. {
  61. cout << "\n You have chosen multiplication. Please input the first number. \n" << endl;
  62. cin >> Number1;
  63. cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
  64. cin >> Number2;
  65. cout << "\n The answer is " << Multiplication(Number1, Number2) << endl;
  66. }
  67. else
  68. {
  69. if (operation==4)
  70. {
  71. cout << "\n You have chosen division. Please input the first number. \n" << endl;
  72. cin >> Number1;
  73. cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
  74. cin >> Number2;
  75. cout << "\n The answer is " << Division(Number1, Number2) << endl;
  76. }
  77. else
  78. {
  79. cout << "\n The choice you have selected is invalid. Please re-open the program. \n" << endl;
  80. }
  81. }
  82. }
  83. }
  84.  
  85.  
  86. cout << "\n Thank you for using the program. \n";
  87. cin >> systempause;
  88. return 0;
  89. }
Add Comment
Please, Sign In to add comment