Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please use c++ to solve this question: Design and implement a calculator that su

ID: 3758089 • Letter: P

Question

please use c++ to solve this question: Design and implement a calculator that supports all four basic functionalities like add, subtract, divide and multiply using functions. Specifically, perform the following: - Use functions to perform all these operations - Your functions must "return" the result of the computation back to the main() program, which displays this on screen. - Use a while(1) and switch to create a "menu" like interfact that allows the user to enter two numbers, and pick an operation of choice. please use c++ to solve this question: Design and implement a calculator that supports all four basic functionalities like add, subtract, divide and multiply using functions. Specifically, perform the following: - Use functions to perform all these operations - Your functions must "return" the result of the computation back to the main() program, which displays this on screen. - Use a while(1) and switch to create a "menu" like interfact that allows the user to enter two numbers, and pick an operation of choice. please use c++ to solve this question: Design and implement a calculator that supports all four basic functionalities like add, subtract, divide and multiply using functions. Specifically, perform the following: - Use functions to perform all these operations - Your functions must "return" the result of the computation back to the main() program, which displays this on screen. - Use a while(1) and switch to create a "menu" like interfact that allows the user to enter two numbers, and pick an operation of choice. please use c++ to solve this question: Design and implement a calculator that supports all four basic functionalities like add, subtract, divide and multiply using functions. Specifically, perform the following: - Use functions to perform all these operations - Your functions must "return" the result of the computation back to the main() program, which displays this on screen. - Use a while(1) and switch to create a "menu" like interfact that allows the user to enter two numbers, and pick an operation of choice.

Explanation / Answer

#include <iostream>
using namespace std;
int add(int op1, int op2)
{
return op1+op2;
}
int sub(int op1, int op2)
{
return op1-op2;
}
int mul(int op1, int op2)
{
return op1*op2;
}
int divide(int op1, int op2)
{
return op1/op2;
}
int main()
{
int op1, op2;
char opnd, proceed;
while(1)
{
cout<<"Enter the first operand: ";
cin>>op1;
cout<<"Enter the second operand: ";
cin>>op2;
cout<<"Enter the operator: ";
cin>>opnd;
switch(opnd)
{
case '+': cout<<op1<<" + "<<op2<<" = "<<add(op1, op2)<<endl; break;
case '-': cout<<op1<<" - "<<op2<<" = "<<sub(op1, op2)<<endl; break;
case '*': cout<<op1<<" * "<<op2<<" = "<<mul(op1, op2)<<endl; break;
case '/': cout<<op1<<" / "<<op2<<" = "<<divide(op1, op2)<<endl; break;
default : cout<<"Invalid operator."<<endl;
}
cout<<"Do you want to perform another operation (Y/N): ";
cin>>proceed;
if(proceed == 'N')
exit(0);
}
}