Question: And my code is #include stdafx.h #include using namespace std; void main() { double D1(0); double D2(0); double D3(0); char Operator; const bool T(true), F(false);

ASSIGNMENT: Modify Lab Five such that you use functions for each math

And my code is

#include "stdafx.h"

#include

using namespace std;

void main()

{

double D1(0);

double D2(0);

double D3(0);

char Operator;

const bool T(true), F(false);

do

{

cout

cin >> D1;

cout

cin >> Operator;

} while (Operator == 'C');

while (!F)

{

switch (Operator)

{

case '+':

cout

cin >> D2;

D3 = D1 + D2;

cout

T;

break;

case '-':

cout

cin >> D2;

D3 = D1 - D2;

cout

T;

break;

case '*':

cout

cin >> D2;

D3 = D1 * D2;

cout

T;

break;

case'/':

cout

cin >> D2;

if (D2 == 0)

{

cout

cin >> D2;

}

else D3 = D1 / D2;

cout

T;

break;

case 'C':

case 'c':

D1 = 0;

cout

cin >> D1;

T;

break;

case 'X':

case 'x':

F;

exit(0);

break;

default:

F;

cout

}

}

D1 = D3;

cout

}

Return operator is not working and letter C and X is not working

Please fix my problem.. Thank you

ASSIGNMENT: Modify Lab Five such that you use functions for each math calculation (Add, Subtract, Multiply, and Divide). Pass in parameters to each function for the values to use and the functions will return the result. Use a function to read in the numbers involved. These numbers will be doubles. Also write a function that reads in the operator and returns a boolean - true if the operator is valid, false if not valid. This function will have two parameters. First is a "C-type" string of characters containing the valid operators. The second is a reference parameter where the operator will be placed if the operator entered is valid.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include using namespace std Function to check if the entered operator is valid bool isValidOperatorconst char operators char operatorChar cout Please ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!