Hi
I need to perogram the simple Calculatotr,
Acceptable operators.'
+ : Add
- : Subtract
* : Multiply
/ : Divide
^ : Power ( raise left oprqnd to the power of the rifgt operand )
q or Q = Quit
This is a progarm that I wrote :
#include <iostream>
#include <cmath>
using namespace std;
void Instructions();
float do_next_op(char op, float o, float
CAV);
void startCalculatorProgram();
void main()
{
startCalculatorProgram();
}
void Instructions()
{
cout << "Begin Calculater " << endl;
cout << "Instructions are:" << endl;
}
float do_next_op(char op, float o, float CAV)
{
switch (op)
{
case '+':
return CAV + o;
break;
case '-':
return CAV - o;
break;
case '*':
return CAV * o;
break;
case '/':
return CAV / o;
break;
case '^':
return pow(CAV, o);
break;
default:
cout << "the input you choosed is not correct" << endl;
}
void startCalculatorProgram()
{
Instructions();
float accumulatedValue = 0.0;
char op;
float o;
while (true)
{
cin >> op;
if (op == 'q' || op == 'Q')
{
cout << "ByeBye..." << endl;
break;
}
cin >> o;
accumulatedValue = do_next_op(op, o, accumulatedValue);
cout << "Result so far is " << accumulatedValue << endl;
}
I want to build the program, and I got two errors
Error 1 error C2601: 'startCalculatorProgram' : local function definitions are illegal c:\users\nimasafa\documents\visual studio 2008\projects\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming.cpp 46 nimasafaeian__cs 210 Programming
Error 2 fatal error C1075: end of file found before the left brace '{' at 'c:\users\nimasafa\documents\visual studio 2008\projects\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming.cpp(46)' was matched c:\users\nimasafa\documents\visual studio 2008\projects\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming\nimasafaeian__cs 210 programming.cpp 64 nimasafaeian__cs 210 Programming
Can you please help me out to solve my problems.
Thank you so much