67 060
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #2734 in C++ for LAJJA

Question #2734
Write program that allows user to enter two numeric values. Then let user enter a single character as desired operation: 'a' for add, 's' for subtract, 'm' for multiply, or 'd' for divide. perform arithmetic operationn that the user selects and display the results
Expert's answer
#include <iostream>
using namespace std;

int main()
{
& double a, b;
& char op;
& cout << "Enter two values a and b\n";
& cout << "a = ";
& cin >> a;
& cout << "b = ";
& cin >> b;
& cout << "Enter the letter for operation\n"
& lt;< " 'a' - add: a+b\n"
& lt;< " 's' - substract: a-b \n"
& lt;< " 'm' - multiply a*b\n"
& lt;< " 'd' - divide a/b\n";
& cin >> op;
& switch (op)
& {
& case 'a':& cout << " a + b = " << a+b;
break;

& case 's':& cout << " a - b = " << a-b;
break;

& case 'm':& cout << " a * b = " << a*b;
break;

& case 'd':& cout << " a / b = " << a/b;
break;

& default: cout << "Incorrect letter for operation";
& };
& cout << endl;
& return 0;

};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions