Thanks as always everyone!!!
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char calc = ' ';
int num1 = 0;
int num2 = 0;
int total = 0;
//enter input data
cout << "Type A for addition, S for subtraction, M for multiplication, D for division:";
cin >> calc;
calc = toupper(calc);
switch (calc)
{
case 'A':
cout << "Enter the first number you would like to add:" << endl;
cin >> num1;
cout << "Enter the second number you would like to add:" << endl;
cin >> num2;
total = num1 + num2;
cout << "Your total is: " << total << endl;
break;
case 'S':
cout << "Enter the first number you would like to subtract:" << endl;
cin >> num1;
cout << "Enter the second number you would like to subtract:" << endl;
cin >> num2;
total = num1 - num2;
cout << "Your total is: " << total << endl;
break;
case 'M':
cout << "Enter the frist number you would like to multiply:" << endl;
cin >> num1;
cout << "Enter the second number you would like to multiply:" << endl;
cin >> num2;
total = num1 * num2;
cout << "Your total is: " << total << endl;
break;
case 'D':
cout << "Enter the first number you would like to divide:" << endl;
cin >> num1;
cout << "Enter the second number you would like to divide:" << endl;
cin >> num2;
total = num1 / num2;
cout << "Your total is: " << total << endl;
break;
default:
cout << "Error" << endl;
} //end switch
return 0;
} //end of main function

New Topic/Question
Reply


MultiQuote


|