I found this site while looking for any help to answer my issues with my program. I currently am a student at University of Phoenix, and this is my first programming class in C. Our teacher strongly encourages team and class cooperation so that our programs work. I have asked for help from my classmates, and no one has responded. So I am using my teachers advice and finding someone, anyone to help me.
My program is supposed to do validity checks and I wanted mine to also prompt the user to re-enter the subtotal if a charcater was entered instead of a digit. Another thing I noticed is I have to hit the enter key twice before the rest of my program runs. Cannot figure that one out. Below is my problem program. Any help at this point would be greatly appreciated.
Code:
/* Kudler Food Tax Calculator */
//by TDankert
//July 30, 2007
#include <stdio.h>
#include <ctype.h>
main()
{
//Variables Defined
float fSubtotal, fDelmar, fEncinitas, fLajolla, fCheck;
char cResponse;
fSubtotal=0;
fCheck=0;
cResponse = '\0';
//Taxrate Defined
fDelmar=.0725;
fEncinitas=.075;
fLajolla=.0775;
//User Requirements
printf("\nWelcome to Kudler Fine Foods,\n\nWe hope you enjoyed your shopping experience.\n");
printf("\n\n\n\tPlease Enter your Subtotal: $");
scanf("%f, %c", &fSubtotal, &cResponse);
while (fSubtotal < fCheck){
printf("\nPlease Re-enter your Subtotal: $");
scanf("%f, %c", &fSubtotal, &cResponse );
}//end while loop
while (isdigit(cResponse)){
printf("\nPlease Re-enter your Subtotal: $");
scanf("%f, %c", &fSubtotal, &cResponse );
}//end while loop
//Del Mar Outputs
printf("\n\tTotal Sales Tax for Del Mar is $%.2f\n", fSubtotal*fDelmar);
printf("\tYour Del Mar Total is $%.2f\n", fSubtotal*fDelmar+fSubtotal);
//Encinitas Outputs
printf("\n\tTotal Sales Tax for Encinitas is $%.2f\n", fSubtotal*fEncinitas);
printf("\tYour Encinitas Total is $%.2f\n\n", fSubtotal*fEncinitas+fSubtotal);
//La Jolla Outputs
printf("\n\tTotal Sales Tax for La Jolla is $%.2f\n", fSubtotal*fLajolla);
printf("\tYour La Jolla Total is $%.2f\n\n", fSubtotal*fLajolla+fSubtotal);
//Ending Outputs
printf("\n\nThank You for Shopping Kudler Fine Foods.\n");
printf("\n\tHave a Nice Day!");
getch();
}//End Tax Calculator