subject

In this lab, you complete a partially written c++ program that includes a function that returns a value. the program is a simple calculator that prompts the user for two numbers and an operator ( +, -, *, or / ). the two numbers and the operator are passed to the function where the appropriate arithmetic operation is performed. the result is then returned to the main()function where the arithmetic operation and result are displayed. for example, if the user enters 3, 4, and *, the following is displayed: 3 * 4 = 12

the source code file provided for this lab includes the necessary variable declarations and input and output statements. comments are included in the file to you write the remainder of the program.

instructions

write the c++ statements as indicated by the comments.
execute the program by clicking the run button at the bottom of the screen.

draft:

// 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

int performoperation(double numberone, double numbertwo, string op);
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;
return 0;
} // end of main() function

// write performoperation function here
int performoperation(double numberone, double numbertwo, std: : string(op)){
double result;
if (op == "+")
result = numberone + numbertwo;
else if (op == "-")
result = numberone - numbertwo;
else if (op == "*")
result = numberone*numbertwo;
else if (op == "/")
result = numberone/numbertwo;
else
cout< < "wrong input. try again.";
return result;
}

it's already working but it says that there's something wrong with the declared performoperation

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
Amanda needs to create an informative print brochure for her local library’s fundraiser dinner. what critical detail must she have before she starts designing the brochure?
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Choose the answers that best complete each sentence. on average,are more expensive than other kinds of postsecondary schools. the cost of room and board includes. to save money, some students attend auniversity in their home state.
Answers: 2
question
Computers and Technology, 24.06.2019 08:30
Why might you choose to create a functional resume
Answers: 1
You know the right answer?
In this lab, you complete a partially written c++ program that includes a function that returns a va...
Questions
Questions on the website: 13722367