I am working on program and i'm not sure how to validate the user input. Also when i complie it. It does not return the proper answer the box just exits. Can anyone give me any suggestions?
# include <stdio.h> void main(void) {
int iResponse = 0; //entering the variables in float float cost = 0.0; float delmar = .0725; float encinitas = .075; float lajolla = .0775; //entering printf("\n1\tlajolla\n"); printf("2\tdelmar\n"); printf("3\tencinitas\n"); printf("\nPlease select a category (13): "); scanf("%d", &iResponse); switch (iResponse) { case 1: printf("\nYou selected la jolla\n"); case 2: printf("You selected delmar\n"); case 3: printf("You selected encinitas\n"); printf ("enter sales price please\n"); scanf ("%f",& cost); printf ("the delmar sales tax is %.2f\n", delmar * cost); printf ("the encinitas sales tax is %.2f\n", encinitas * cost); printf ("the lajolla sales tax is %.2f\n", lajolla * cost); printf ("\n"); printf ("the total for delmar is %.2f\n", delmar * cost + cost); printf ("the total for encinitas is %.2f\n", encinitas * cost + cost); printf ("the total for lajolla is %.2f\n", lajolla * cost + cost); getchar(); }