Start New Discussion within our Software Development Community

I am just trying to end this program when the user chooses x or X but without the default "Enter a valid operator." The rest of the program works great (thanks to previous help). Sorry this isn't pasting perfectly.

do 
		   {
			   cout << "Enter an operation: + - * /  (or enter X to exit):"; cin >> oper;
			   switch (oper)
			   {
				   case '+':
					cout << "Enter a number: "; cin >> num; 
					tot = tot + num;
					cout << "Current total is " << tot << endl;
					break;
				   case '-':
			   		cout << "Enter a number: "; cin >> num;
					tot = tot - num;
					cout << "Current total is " << tot << endl;
					break;
				   case '*':
			   		cout << "Enter a number: "; cin >> num;
					tot = tot * num;
					cout << "Current total is " << tot << endl;
					break;
				   case '/':
			   		cout << "Enter a number: "; cin >> num;
					if (num == 0)
					{
					   cout << "Can not divide by zero!" << endl;
					}
					else
					{
					tot = tot / num;
					}
					cout << "Current total is " << tot << endl;
					break;
				   default: cout << "Enter a valid operator." << endl;
			   }
		   }while (oper != 'X' && oper != 'x');

This solved it.

case 'x': cout << ""; break;
case 'X': cout << ""; break;
This question has already been answered. Start a new discussion instead.