#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float user1;
float user2;
float sum;
char choice;
for (;;)
do {
cout<<"Calculator";
cout << "Enter your first number" << endl;
cin >> user1;
cout << "Enter your function \n";
cout << "+ \n";
cout << "- \n";
cout << "x \n";
cout << "/ \n";
cin >> choice;
case "+": //addition
cout << "Enter your second number" << endl;
cin >> user2;
cout << user1 + user2;
cout << endl << "Sum equals" << sum;
break;
case "-": //subtraction
cout << "Enter your second number" << endl;
cin >> user2;
cout << user1 - user2;
cout << endl << "Sum equals" << sum;
break;
case "x": //multiplication
cout << "Enter your second number" << endl;
cin >> user2;
cout << user1 * user2;
cout << endl << "Sum equals" << sum;
break;
case "/": //division
cout << "Enter your second number" << endl;
cin >> user2;
cout << user1 / user2;
cout << endl << "Sum equals" << sum;
break;
do
{
cout << "Press 'q' to quit or 'c' to continue: ";
cin >> choice;
} while (choice != 'c' && choice != 'q');
} while (choice == 'c');
system("PAUSE");
return 0;
}
Ok, so I think I need a switch somewhere for the cases... but not too sure. I'm trying to make a calculator where there's an option to enter q for quit... not even sure if i have that right. Any help would be great!