Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- void calc(void);
- void result(double a, double b, char &);
- int main()
- {
- double operand1, operand2;
- char A, N, P, R, F, T, Q, letter;
- calc();
- cout << endl << "Please enter the one the mentioned operators" << endl;
- cin >> letter;
- if (letter == '+'|| letter == '-'|| letter == '*' || letter == '/'|| letter == '%' || letter == 'P' || letter == 'A' || letter == 'N')
- result(operand1, operand2, letter);
- system("Pause");
- return 0;
- }
- void result(double a, double b, char &c)
- {
- cout << "Please enter the first integer" << endl;
- cin >> a;
- cout << "Please enter the second integer" << endl;
- cin >> b;
- if (c = '+'){
- a + b;
- }
- if (c = '-'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The difference of both of these numbers is " << a - b << endl << endl;
- }
- if (c = '*'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The product of both of these numbers is " << a * b << endl << endl;
- }
- if (c = '/'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The quotient of both of these numbers is " << a / b << endl << endl;
- }
- if (c = '%'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The quotient of both of these numbers is " << a / b << endl << endl;
- }
- if (c = 'P'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The power of b over a is " << pow(a,b) << endl << endl;
- }
- if (c = 'A'){
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The average of both numbers is " << (a + b) / 2 << endl << endl;
- }
- if (c = 'N'){
- a < b;
- cout << "Operand 1 is " << a << '\t' << "Operand 2 is " << b << endl << "The average of both numbers is " << a + b / 2 << endl << endl;
- }
- }
- void calc(void)
- {
- cout << "Operators\t" << "Functions" << endl << endl;
- cout << "+\t" << '\t' << "Addition" << endl;
- cout << "-\t" << '\t' << "Subtraction" << endl;
- cout << "*\t" << '\t' << "Multiplication" << endl;
- cout << "/\t" << '\t' << "Division" << endl;
- cout << "%\t" << '\t' << "Division(with remainders)" <<endl;
- cout << "A\t" << '\t' << "average of two numbers" << endl;
- cout << "N\t" << '\t' << "minimum of two numbers" << endl;
- cout << "P\t" << '\t' << "a^b" <<endl;
- cout << "R\t" << '\t' << "reciprocal" << endl;
- cout << "F\t" << '\t' << "factorial" << endl;
- cout << "T\t" << '\t' << "sqaure root" << endl;
- cout << "Q\t" << '\t' << "Quit" << endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement