2013-02-16T23:34:50-05:00
Create a C++ program that performs 4 mathematical operations such as addition, subtraction, multiplication and division.
The numbers to be entered must have 1 whole number and with 2 decimal points.
The output must be in the center of the screen.
1
2013-02-19T09:20:30-0500
#include <conio.h> #include <iomanip> #include <iostream> using namespace std; int main() { double a, b; char sign; double result; cout << "Enter an expression: "; cin >> setprecision(2) >> a >> sign >> setprecision(2) >> b; switch (sign) { case '+': result = a + b; break; case '*': result = a * b; break; case '-': result = a - b; break; case '/': result = a / b; break; default: cout << "Invalid input." << endl; _getch(); return -1; } cout << setw(40) << result << endl; _getch(); 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 !
Learn more about our help with Assignments:
C++
Comments