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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 06:30, titalili0204
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
image
Computers and Technology, 24.06.2019 17:40, hughesnatalia2003
File i/o activity objective: the objective of this activity is to practice working with text files in c#. for this activity, you may do all code in the main class. instructions: create an app that will read integers from an input file name numbers. txt that will consist of one integer per record. example: 4 8 25 101 determine which numbers are even and which are odd. write the even numbers to a file named even. txt and the odd numbers to a file named odd. txt.
Answers: 3
image
Computers and Technology, 24.06.2019 18:30, txa95
After making a powerpoint presentation about a new line of clothing designs, henri notices that he used the word “gorgeous” on nearly every slide. what would be the  best  way to add more variety to his wording by using tools within powerpoint? using the thesaurus under the view tab, and then using the find dialog box to find and replace every instance of “gorgeous”using the spelling checker under the view tab, and then using the find dialog box to find every instance of “gorgeous” and change some of themusing the thesaurus under the review tab, and then using the find dialog box to find every instance of “gorgeous” and change some of themusing the spelling checker under the review tab, and then using the find dialog box to find and replace every instance of “gorgeous”
Answers: 2
image
Computers and Technology, 25.06.2019 00:30, aleiahmartin
Which email writing etiquette should ariel follow to let people know that she received their message? a. reply to their messages immediately b. use formal language c. specify the email's intent in the subject field d. be direct when writing the reply
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 in other subjects:

Konu
Mathematics, 28.01.2022 20:30