1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
int startup()
{
system("title choosing operation");
cout << "Enter operation (add, subtract, multiply, divide,power,+,-,*,/,^)\n>";
}
double power(double a, double b)
{
return pow(a,b);
}
double divide(double a, double b)
{
return a / b;
}
double multiply(double a, double b)
{
return a * b;
}
double subtract(double a, double b)
{
return a - b;
}
double add(double a, double b)
{
return a + b;
}
int main(int nNumberofArgs, char* pszArgs[])
{
double A;
double B;
string operation;
cout << "NOTE: If the operation doesn't exist the program will exit." << endl;
startup();
cin >> operation;
if (operation == "add"||operation=="+")
{
system("title adding");
cout << "Enter first number: ";
cin >> A;
cout << "Enter second number: ";
cin >> B;
cout << add(A,B) << endl;
startup();
cin >> operation;
}
if (operation == "subtract"||operation=="-")
{
system("title subtracting");
cout << "Enter first number: ";
cin >> A;
cout << "Enter second number: ";
cin >> B;
cout << subtract(A,B) << endl;
startup();
cin >> operation;
}
if (operation == "multiply"||operation=="*")
{
system("title multiplying");
cout << "Enter first number: ";
cin >> A;
cout << "Enter second number: ";
cin >> B;
cout << multiply(A,B) << endl;
startup();
cin >> operation;
}
if (operation == "divide"||operation=="/")
{
system("title dividing");
cout << "Enter first number: ";
cin >> A;
cout << "Enter second number: ";
cin >> B;
cout << divide(A,B) << endl;
startup();
cin >> operation;
}
if (operation == "power"||operation=="^")
{
system("title powering");
cout << "Enter first number: ";
cin >> A;
cout << "Enter second number: ";
cin >> B;
cout << power(A,B) << endl;
startup();
cin >> operation;
}
system("title invalid operation");
cout << "Not an operation";
system("PAUSE >nul");
return 0;
}
|