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

This is a C++ program Write a program that allows the user to enter two numeric

ID: 3551495 • Letter: T

Question

This is a C++ program


Write a program that allows the user to enter two numeric values. Then let the user enter a single character as the desired operation, for example 'A', 'a', or '+' for add. The user should be able to enter uppercase initial, lowercase initial, or the arithmetic symbol. Perform the arithmetic operation that the user selects and displays the results.




This is for Chapter 3 in Object Oriented Programming Using C++ please only use things that would have been learned in the first 3 chapters. I dont need a bunch of code that hasnt been learned yet. Points will be awarded promptly.

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

float num1,num2,result;

char opr;

cout<<"Enter first number : ";

cin>>num1;

cout<<"Enter second number : ";

cin>>num2;

cout<<"Enter 'A' or 'a' or '+' for addition"<<endl;

cout<<"Enter 'S' or 's' or '-' for subtraction"<<endl;

cout<<"Enter 'M' or 'm' or '*' for multiplication"<<endl;

cout<<"Enter 'D' or 'd' or '/' for division"<<endl;

cout<<"Enter your choice : ";

cin>>opr;

if(opr=='A'||opr=='a'||opr=='+')

result=num1+num2;

else if(opr=='S'||opr=='s'||opr=='-')

result=num1-num2;

else if(opr=='M'||opr=='m'||opr=='*')

result=num1*num2;

else if(opr=='D'||opr=='d'||opr=='/')

result=num1/num2;

cout<<endl<<"result = "<<result;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote