Write a program thataccepts 3 values as input,the first input value will be oneo
ID: 3616388 • Letter: W
Question
Write a program thataccepts 3 values as input,the first input value will be oneof four operationcodes either "A" for addition, "M" for multiplication, "S" forsubtraction or "D" for division,
the other two input values will be numbers. The computer isto perform a computation on the two numbers as determined by theoperation code.
The result of the computation as well as the original input is tobe written as output. An error message should be output if theoperation code is invalid. Write a program thataccepts 3 values as input,the first input value will be oneof four operation
codes either "A" for addition, "M" for multiplication, "S" forsubtraction or "D" for division,
the other two input values will be numbers. The computer isto perform a computation on the two numbers as determined by theoperation code.
The result of the computation as well as the original input is tobe written as output. An error message should be output if theoperation code is invalid.
Explanation / Answer
please rate - thanks #include using namespace std; int main() {char oper,op; int num1,num2,answer,valid=1; coutoper; coutnum1; coutnum2; if(oper=='A') {answer=num1+num2; op='+'; } else if(oper=='S') {answer=num1-num2; op='-'; } else if(oper=='M') {answer=num1*num2; op='*'; } else if(oper=='D') {answer=num1/num2; op='/'; } else {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.