I've learned the basics of C++ and im trying to write a calculator that can add subtract multiply and divide. I've gone through this code several times and I can't figure out what the problem is.
[ code ]
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int FirstNumber()
{
int FN;
cout << "choose the first number you want to use in the calculation" << endl;
cin >> FN;
return FN;
}
int SecondNumber()
{
int SN;
cout << "choose the second number you want to use in the calculation" << endl;
cin >> SN;
return SN;
}
char GetOperator()
{
char useroperator;
cout << "Choose what operator you want to use.+,-,*,/ " << endl;
cin >> useroperator;
return useroperator;
}
int Calculation(int numb, int snumb, char op)
{
if (op== '+')
return numb + snumb;
if (op == '-')
return numb - snumb;
if (op == '*')
return numb * snumb;
if (op == '/')
return numb / snumb;
}
void PrintResult(int result)
{
cout << "The Result of this equation is : ";
cout << result;
}
int main()
{
int FinalFirst = FirstNumber();
char op = GetOperator();
int FinalSecond = SecondNumber();
int result = Calculation(FinalFirst, op, FinalSecond);
PrintResult(result);
system("PAUSE");
}