#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
int number = 0;
float cost = 0.0;
char beverage;
bool validBeverage;
cout << fixed << showpoint << setprecision(2);
do
{
cout << endl << endl;
cout << "Hot Beverage Menu" << endl << endl;
cout << "A: Coffee $1.00" << endl;
cout << "B: Tea $ .75" << endl;
cout << "C: Hot Chocolate $1.25" << endl;
cout << "D: Cappuccino $2.50" << endl <<endl << endl;
cout << "Enter the beverage A,B,C, or D you desire" << endl;
cout << "Enter E to exit the program" << endl << endl;
cin >> beverage;
switch(beverage)
{
case'a':
case'A':
case'b':
case'B':
case'c':
case'C':
case'd':
case'D': validBeverage = true;
break;
default: validBeverage = false;
}
if (validBeverage == true)
{
cout << "How many cups would you like?" << endl;
cin >> number;
}
switch (beverage)
{
case'a':
case'A': cost = number * 1.0;
cout << "The total cost is $ " << cost << endl;
break;
case'b':
case'B': cost = number * .75;
cout << "The total cost is $ " << cost << endl;
break;
case'c':
case'C': cost = number * 1.25;
cout << "The total cost is $ " << cost << endl;
break;
case'd':
case'D': cost = number * 2.5;
cout << "The total cost is $ " << cost << endl;
break;
case'e':
case'E': cout << "Please come again." << endl;
break;
default:cout << " The selection you made is invalid." << endl;
cout << " Try again please" << endl;
}
} while (beverage != e || beverage != E);
return 0;
}
Hello all! I am writing my first loop-based program and have run into just one difficulty in getting it to compile. Whenever I go to run this program, I receive the following set of errors:
Thank you. That fixes the error of an undeclared identifier, but the program still does not exit after the user selects 'e' or 'E'. Is there something I am missing about the while() line?