Help with sample tax program

• 05-15-2003
DaMonsta
Help with sample tax program
I am having trouble with a sample tax program that I am trying to write. If everything is working correctly, you should be able to enter a salary, and have state and federal taxes computed and printed on the screen along with corresponding salary. After entering all salaries, total salary and taxes should be printed. What I have so far is below. What am I doing wrong or missing? Thanks.

#include <stdio.h>

#define federal_rate .23 /* Federal Tax Rate */
#define state_rate .07 /* State Tax Rate */

double salary, total_salary , federal_taxes , total_federal_taxes , state_taxes , total_state_taxes ;

int main(void){
while (scanf("%lf", &salary) == 1){
federal_taxes = federal_rate * salary;
state_taxes = state_rate * salary;
printf("%s%5.2f\n%s%5.2f\n%s5.2f\n\n",
"The salary is ",salary, "The federal tax
is ",federal_taxes, "The state tax is ",state_taxes);
total_salary += salary; total_federal_taxes += federal_taxes; total_state_taxes += state_taxes;
}
printf("%s%5.2f\n%s5.2f\n%s%5.2f\n\n","Total salaries ",total_salary,"Total Federal taxes ",
total_federal_taxes,"Total State taxes ",
total_state_taxes);
return 0;
}
• 05-15-2003
walker128
Basically there isn't much problem with your program, to end your prgram with calculation of total salary,federal taxes and state taxes, just type in a few salaries and then type a single alphabet then your program will stop and give you the total.

check this and compare with the on u posted-->
printf("%s%5.2f\n%s%5.2f\n%s%5.2f\n\n","The salary is ",salary, "The federal tax is ",federal_taxes, "The state tax is ",state_taxes);

you left out a "%"

try this out.......

#include <stdio.h>

#define federal_rate .23 /* Federal Tax Rate */
#define state_rate .07 /* State Tax Rate */

double salary, total_salary , federal_taxes , total_federal_taxes , state_taxes , total_state_taxes ;

int main(void)
{