Hey fellow programmers....
I am working on a basic tax calcualtion for a class and I am having a little trouble. I keep getting an error when trying to execute the program. I am also trying to make the program calculate and display the total amount for all three locations and not just one each time. I know there has to be a simple command I can insert to it calculates all three at one and time and displays the total. Anyone experienced programmers point out what I might be doing wrong? Thanks so much to anyone that can help.
Here is the code I have:
Code:
#include <stdio.h>//header
#include <ctype.h>//isdigit header
main()
{//start
int iResponse = 0;//town selection
float fCost;//calculation operator
fCost = 0;
printf ("\n\tThank you for using the Kudler tax calculation utility.\n");
printf ("\n\tPlease select your location to recieve your taxable total.\n");
Printf ("\n 1\tDel Mar\n");
Printf (" 2\tEncinitas\n");
Printf (" 3\tLa Jolla\n");
printf("\n Please select your location (1-3): ");
for(;;){
if (scanf("%d", &iResponse)==0)
break;
{
puts("Invalid number, please try again");
/* clear the input buffer */
while((iResponse = getchar()) != '\n' && iResponse != EOF) {}
switch (iResponse)
case 1:
printf("\n Welcome Del Mar Associate.\n");
printf(" Please enter your sub-total: $");
scanf("\n%f", &fCost);//sale sub-total
printf(" --------------------------------\n");
printf(" Your total tax is $%.2f\n", fCost * .0725);//in-line calculation
printf(" The total amount owed is $%.2f\n", fCost * (1+.0725));//in-line calculation
break;
getchar();
case 2:
printf("\n Welcome Encinitas associate.\n");
printf(" Please enter your sub-total: $");
scanf("%f", &fCost);//sale sub-total
printf(" --------------------------------\n");
printf(" Your total tax is $%.2f\n", fCost * .075);//in-line calculation
printf(" The total amount owed is $%.2f\n", fCost * (1+.075));//in-line calculation
break;
getchar();
case 3:
printf("\n Welcome La Jolla associate.\n");
printf(" Please enter your sub-total: $");
scanf("%f", &fCost);//sale sub-total
printf(" --------------------------------\n");
printf(" Your total tax is $%.2f\n", fCost * .0775);//in-line calculation
printf(" The total amount owed is $%.2f\n", fCost * (1+.0775));//in-line calculation
break;
getchar();
}// end calc
getchar();//keeps application viewable on screen
}// end selection