I have an assignment where I am prompted to enter a number and the program will figure the tax on the amount entered. This will be for 3 separate store locations. I finally have the program displaying correctly on the screen, but the math is no good and it won't figure to the dollars and cents (tax is on 125.00 at 3 fifferent tax rates). I am using %.2f in the scanf and printf areas, but I have to get the program to recognize the floating point, not integers. Below is the code. PLease, could someone give me some advice. Class is on thursday and I still need to do a flowchart in Visio.
Thank you
[code=c]
/*Tax calculator for Kudler Fine Foods*/
/*This program is designed to calculate the tax on the taxable dollar amount of each purchase at each Kudler Fine Foods store*/
#include<stdio. h>
int main (void)
{
int tax_input;
tax_input=tax_c alculator();
printf ("%.2f\n", tax_input);
return 0;
}
float tax_calculator (void)
{
float iOperand1;
printf ("\nKudler Fine Foods tax calculator\n");
printf ("\nEnter the amount of the total purchase that is taxable at the Del Mar location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the Del Mar location is %.2f\n", iOperand1*.0725 );
getchar();
printf ("\nEnter the amount of the total purchase that is taxable at the Encinitas location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the Encinitas location is %2.f\n", iOperand1*.075) ;
getchar();
printf ("\nEnter the amount of the total purchase that is taxable at the La Jolla location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the La Jolla location is %.2f\n",
iOperand1*.0775 );
iOperand1=getch ();
return iOperand1;
}[/code]
Thank you
[code=c]
/*Tax calculator for Kudler Fine Foods*/
/*This program is designed to calculate the tax on the taxable dollar amount of each purchase at each Kudler Fine Foods store*/
#include<stdio. h>
int main (void)
{
int tax_input;
tax_input=tax_c alculator();
printf ("%.2f\n", tax_input);
return 0;
}
float tax_calculator (void)
{
float iOperand1;
printf ("\nKudler Fine Foods tax calculator\n");
printf ("\nEnter the amount of the total purchase that is taxable at the Del Mar location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the Del Mar location is %.2f\n", iOperand1*.0725 );
getchar();
printf ("\nEnter the amount of the total purchase that is taxable at the Encinitas location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the Encinitas location is %2.f\n", iOperand1*.075) ;
getchar();
printf ("\nEnter the amount of the total purchase that is taxable at the La Jolla location: ");
getchar();
scanf ("%.2lf", &iOperand1);
getchar();
printf ("The tax on the purchase at the La Jolla location is %.2f\n",
iOperand1*.0775 );
iOperand1=getch ();
return iOperand1;
}[/code]
Comment