Question
Simple Calculator: I am having an error stating: expected unqualified-id before '{' token File: Calculator.cpp Line: 43 // Write performOperation function here double performOperation(double numberOne,double
Simple Calculator:
I am having an error stating:
expected unqualified-id before '{' token
File: | Calculator.cpp |
Line: | 43 |
// Write performOperation function here double performOperation(double numberOne,double numberTwo,string operation);
this is lines 41 and 42. Any suggestions as to what is wrong?
// Calculator.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers. // Input: Interactive // Output: Result of arithmetic operation
#include #include using namespace std;
// Write performOperation() function declaration here double performOperation(double,double,string);
int main() { double numberOne, numberTwo; string operation; double result; cout << "Enter the first number: "; cin >> numberOne; cout << "Enter the second number: "; cin >> numberTwo; cout << "Enter an operator (+.-.*,/): "; cin >> operation; // Call performOperation method here result =performOperation(numberOne,numberTwo,operation);
cout << numberOne; cout << " " << operation << " "; cout << numberTwo; cout << " = "; cout << result << endl; system("pause"); return 0;
} // End of main() function // Write performOperation function here double performOperation(double numberOne,double numberTwo,string operation); { double result = 0; if(operation == '+')
result = numberOne + numberTwo; else if(operation == '-') result = numberOne - numberTwo; else if(operation == '*'); result = numberOne * numberTwo;
else if(operation == '/'); result = numberOne / numberTwo;
return result; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started