Help with this simple calculator code

Posts 1–2 of 2 · Page 1 of 1
Help with this simple calculator code
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");
}
Calculation(FinalFirst, op, FinalSecond); -> int, char, int

int Calculation(int numb, int snumb, char op) -> int, int, char

wrong params on the call.
Calculation(FinalFirst, FinalSecond, op);

PS: Next time please use [ code ] tags
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us