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
|
#include <iostream>
//The PROBLEM - is void the right function at all?
void goodEndPrint(double dX, double dY, char chOperatorChoice)
{
using namespace std;
cout << dX << " " << chOperatorChoice << " " << dY << " = " << dX * dY <<
". Yay! Thankyou for using... me, the thinking man's stupid calculator!" << endl << endl;
}
int main()
{
using namespace std;
//Firstly, an introduction to the calculator.
cout << "Welcome to the friendly but very basic calculator!" << endl << endl <<
//The first number.
"Please enter a number: ";
double dX; cin >> dX;
//The operator (I've only set it up for the 4 main operators)
cout << endl << "Now, before you put your function in, I must remind you that I am very basic." <<
endl << "Any function other than +, -, * (times) or / (divide) will cause me to EXPLODE." <<
endl << "With that in mind," <<
endl << "please enter the operation you would like to perform: ";
char chOperatorChoice;
cin >> chOperatorChoice;
//The second number.
cout << endl << "Enter another number: ";
double dY; cin >> dY;
cout << endl << endl;
//The PROBLEM!
if (chOperatorChoice == '+')
void goodEndPrint(double dX, double dY, char chOperatorChoice);
//Or should I keep it like these ones (boring to write, but at least functionable)?
else if (chOperatorChoice == '-')
cout << dX << " " << chOperatorChoice << " " << dY <<
" = " << dX - dY << ". Yay! Thankyou for using... me, the thinking man's stupid calculator!" << endl << endl;
else if (chOperatorChoice == '*')
cout << dX << " " << chOperatorChoice << " " << dY <<
" = " << dX * dY << ". Yay! Thankyou for using... me, the thinking man's stupid calculator!" << endl << endl;
else if (chOperatorChoice == '/')
cout << dX << " " << chOperatorChoice << " " << dY <<
" = " << dX / dY << ". Yay! Thankyou for using... me, the thinking man's stupid calculator!" << endl << endl;
// What happens if some smartalec messes the operation up.
else cout << "VLADABOOM! See Told you. Humph. I'm only very basic, you know... {sniffle}" << endl << endl;
}
|