Question: This is C + + simple calculator program. Read the instructions carefully also the comments of my code. Provide a code with explaition. The screenshot

This is C++ simple calculator program. Read the instructions carefully also the comments of my code. Provide a code with explaition. The screenshot has the functions for SimpleCalc.h. SimpleCalc.cpp #include "SimpleCalc.h"
#include
void SimpleCalc::Calculate()
{
switch (operation)
{
case'+':
answer = operand1+ operand2;
desc = "addition";
case'/':
//check to see if operand is 0
if(operand2==0)
{
desc ="No division by 0!";
}
else
{
//regular division
desc = "division";
}
break;
default:
//handle an operation that is not acceptable
desc = "That operation is not allowed. Please try again";
}
}
SimpleCalc::SimpleCalc()
{
}
void SimpleCalc::SetOperation(char oper, double op1, double op2)
{
operation = oper;
operand1= op1;
operand2= op2;
//check if operand2=0 and operation is division
//then set desc and don't even call calculate
Calculate();
}
string SimpleCalc::GetResults()
{
//creat a string that says "Your operation is addition: 5+7=12
//or your operation is division: 6/0 Illegal Operation!
//check to see if the operation was illegal or if the operation was not set
//a valid one. Then make a different desc.
//return string;
} Driver.cpp #include "SimpleCalc.h"
#include
using namespace std;
bool DoAnother();
int main()
{
//cout a course header
cout "Welcome to Simple Calculator!";
//declare any variables you need and create a SimpleCalc object
char ans{'y'};
string results;
SimpleCalc calc;
//start a play loop
do {
//ask the user for the operation and the two operands
//use the object to SetOperation
calc.SetOperation(op, num1, num2);
//call GetResults and show them
cout calc.GetResults();
//ask the user if they want to go again
cout "Do you want to calculate another? y/n";
cin >> ans;
} while (DoAnother());
//finish with the loop
//cout a goodbye message
cout "Thank you for using Simple Calculator, Goodbye!";
return 0;
}
bool DoAnother()
{
char ans{'y'};
cout "Do you want to calculate another? y/n";
cin >> ans;
//check
if (ans =='y')
return true;
return false
 This is C++ simple calculator program. Read the instructions carefully also

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!