Im my current code it prompts the user to enter the amount of the item. If a char is entered it causes the program to loop, how do I get the program to check for non numeric inputs? here is my code I need to do a validation check for both the amount and for the store selection
cpp
float Tax[3]={7.25, 7.5, 7.75};
float input = 0.0f;
int choice = 0;
printf("\n\n Please enter the amount of the item: ");
scanf("%f", &input );
printf("\n Please select a Store: (1) Delmar, (2) Encintas, (3) La Jolla\n ? ");
while ((choice < 1) || (choice > 3)){
scanf("%i", &choice ); //use & for storing user input
if ((choice < 1) || (choice > 3))
printf ("\n Enter the number associated to the store: ");
} // end of while loop
printf("\n The sales tax is %f.\n" , input*(Tax[choice-1]/100)); //Tax calculation
return 0;
} // end of main
*edit: You were close with the tags, but you forgot the end code tag.
This post has been edited by Martyr2: 5 Mar, 2008 - 10:27 PM