cout << "Which Beverage would you like to purchase today\n";
cout << "(A) Cola \n";
cout << "(B) RootBeer\n";
cout << "(C) Lemon-Lime \n";
cout << "(D) Grape Soda\n";
cout << "(E) Cream Soda \n";
cout << "(F) Quit Purchase \n";
getChoice (selection);
switch (selection)
{
case 'A' :
case 'a' : cout << "Please enter no more than $1.00 or less than .75 Cents!: ";
cin >> money;
while( money < cost3 || money > 1)
{
cout << "Invalid! Please Re-Enter amount between .75 Cents to a $1.00: " << endl;
cin >> money;
}
case 'B' :
case 'b' :cout << "Please enter no more than $1.00 or less than .75 Cents!: ";
cin >> money;
while( money < cost3 || money > 1)
{
cout << "Invalid! Please Re-Enter amount between .75 Cents to a $1.00: " << endl;
cin >> money;
}
case 'C' :
case 'c' : cout << "Please enter no more than $1.00 or less than .75 Cents!: ";
cin >> money;
while( money < cost3 || money > 1)
{
cout << "Invalid! Please Re-Enter amount between .75 Cents to a $1.00: " << endl;
cin >> money;
}
case 'D' :
case 'd' : cout << "Please enter no more than $1.00 or less than .80 Cents!: ";
cin >> money;
while( money < cost2 || money > 1)
{
cout << "Invalid! Please Re-Enter amount between .80 Cents to a $1.00: " << endl;
cin >> money;
}
break;
case 'E' :
case 'e' : cout << "Please enter no more than $1.00 or less than .80 Cents!: ";
cin >> money;
while( money < cost2 || money > 1)
{
cout << "Invalid! Please Re-Enter amount between .80 Cents to a $1.00: " << endl;
cin >> money;
}
system("PAUSE");
return 0;
}
void getChoice(char & letter )
{
cout << "Enter your choice: ";
cin >> letter;
while ( letter != 'A' && letter != 'a' &&
letter != 'B' && letter != 'b' &&
letter != 'C' && letter != 'c' &&
letter != 'D' && letter != 'd' &&
letter != 'E' && letter != 'e' &&
letter != 'F' && letter != 'f' )
{
cout << "Please enter (A)(B)(C)(D)(E): ";
cin >> letter;
}
You ask to enter letter and then you enter loop inside which you check the letter and print warning, check the letter and print warning, check the letter...
Since you never change variable in this loop, all checks are the same. Perhaps you should have input for the letter inside the loop.
And please use code tags to format your code if you want to ask for help. It is unreadable!
P.S. Perhaps it will be good for you to have more practice with simple programs on loops etc., like from this problem solving site: