QUOTE(Manny @ 6 May, 2007 - 02:07 PM)

QUOTE(Amadeus @ 6 May, 2007 - 02:02 PM)

There are a variety of things you can do...the default case suggested by William_Wilson is a great option...or you could also use the isdigit() function to validate that an digit has been entered instead of an alpha character.
QUOTE
I have tried both options with no luck
Help
Amadeus
This worked just fine thank you
now to tern this in to a class
QUOTE
The problem is that you need to identify the error input before the switch statement. Try the .good() method of the cin operator. It will check to see if an error flags are set..if not, no problem.
Just remember to reset the flags on failure with a cin.clear().
CODE
void showMainMenu()
{
char ch;
int choice;
if ( fullName == "" )
fullName = Getname();
do
{
cout << endl << endl;
cout << "\tWelcome " << fullName << "," << " to Samsung Main menu.\n";
cout << "\tPlease Enter a menu number: 1, 2, 3, 4, or 5 to exit.\n";
cout << endl;
cout << "\t1) Movie Menu 2) Music Menu\n";
cout << "\t3) alibi 4) comfort\n";
cout << "\t5) quit\n";
cout << endl << endl;
cout << "\tPlease enter Main Menu option: ";
cin >> choice;
while (!cin.good())
{
cin.clear();
printf("\n\t\a%c[%d;%dmYou entered a letter ", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << fullName;
printf(", %c[%d;%dmEnter a number from (1 - 4) try agin.\n\n", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cin.get();
cout << "\tPlease enter your Main Menu option: ";
cin >> choice;
}
switch (choice)
{
case 1 : showMovieMenu();
break;
case 2 : music();
break;
case 3 : cout << "\tThe boss was in all day.";
break;
case 4 : comfort();
break;
case 5 : break;
default :
printf("\n\t\a%c[%d;%dmThat's not a good choice ", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
cout << fullName;
printf(", %c[%d;%dmtry agin.\n", 0x1B, BRIGHT, RED, BG_BLACK);
printf("%c[%dm", 0x1B, 0);
}
}
while (choice != 5);
cout << endl << endl;
cout << "\tThank you " << fullName << ", " << "for using Samsungs,\n";
cout << "\tmove and music tool.\n\n\n";
}