Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4. using namespace std;
  5. void calc(void);
  6. void result(double a, double b, char &);
  7. int main()
  8. {
  9.  
  10. double operand1, operand2;
  11. char A, N, P, R, F, T, Q, letter;
  12.  
  13. calc();
  14. cout << endl << "Please enter the one the mentioned operators" << endl;
  15. cin >> letter;
  16.  
  17. if (letter == '+'|| letter == '-'|| letter == '*' || letter == '/'|| letter == '%' || letter == 'P' || letter == 'A' || letter == 'N')
  18. result(operand1, operand2, letter);
  19.  
  20. system("Pause");
  21. return 0;
  22. }
  23.  
  24.  
  25. void result(double a, double b, char &c)
  26. {
  27. cout << "Please enter the first integer" << endl;
  28. cin >> a;
  29. cout << "Please enter the second integer" << endl;
  30. cin >> b;
  31. if (c = '+'){
  32. a + b;
  33. }
  34.  
  35. if (c = '-'){
  36. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The difference of both of these numbers is " << a - b << endl << endl;
  37. }
  38.  
  39. if (c = '*'){
  40. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The product of both of these numbers is " << a * b << endl << endl;
  41. }
  42.  
  43. if (c = '/'){
  44. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The quotient of both of these numbers is " << a / b << endl << endl;
  45. }
  46.  
  47. if (c = '%'){
  48. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The quotient of both of these numbers is " << a / b << endl << endl;
  49. }
  50.  
  51. if (c = 'P'){
  52. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The power of b over a is " << pow(a,b) << endl << endl;
  53. }
  54.  
  55. if (c = 'A'){
  56. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The average of both numbers is " << (a + b) / 2 << endl << endl;
  57. }
  58.  
  59. if (c = 'N'){
  60. a < b;
  61. cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The average of both numbers is " << a + b / 2 << endl << endl;
  62. }
  63.  
  64. }
  65.  
  66.  
  67. void calc(void)
  68. {
  69.  
  70. cout << "Operators\t" << "Functions" << endl << endl;
  71. cout << "+\t" << '\t' << "Addition" << endl;
  72. cout << "-\t" << '\t' << "Subtraction" << endl;
  73. cout << "*\t" << '\t' << "Multiplication" << endl;
  74. cout << "/\t" << '\t' << "Division" << endl;
  75. cout << "%\t" << '\t' << "Division(with remainders)" <<endl;
  76. cout << "A\t" << '\t' << "average of two numbers" << endl;
  77. cout << "N\t" << '\t' << "minimum of two numbers" << endl;
  78. cout << "P\t" << '\t' << "a^b" <<endl;
  79. cout << "R\t" << '\t' << "reciprocal" << endl;
  80. cout << "F\t" << '\t' << "factorial" << endl;
  81. cout << "T\t" << '\t' << "sqaure root" << endl;
  82. cout << "Q\t" << '\t' << "Quit" << endl;
  83.  
  84. return;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement