Write a program that contains the loop
while (scanf("%1f", &salary) == 1) {.......}
within the body of the loop compute a 17% federal withholding tax and a 3% state withholding tax and print these values along with the corresponding salary. Accumulate the sums of all salaries and taxes printed. Print these sums after the program exits the while loop.
My current code:
float salary, federal_tax, state_tax, salary_after_tax, salary_sum, tax_sum, salary_after_tax_sum;
printf("Enter Salary: $");
while (scanf("%lf", &salary) == 1)
{
salary_sum = salary;
federal_tax = salary*(.17);
state_tax = salary*(.03);
tax_sum = federal_tax + state_tax;
salary_after_tax = salary - federal_tax - state_tax;
salary_after_tax_sum = salary_after_tax;
printf("Salary before tax = %lf", salary);
printf("Federal tax = %lf", federal_tax);
printf("State tax = %lf", state_tax);
printf("Salary after tax = %lf\n", salary_after_tax);
break;
}
printf("total salary before tax = %lf", salary_sum);
printf("total tax = %lf", tax_sum);
printf("total salary after tax = %lf\n", salary_after_tax_sum);
system ("pause");
return 0;
}
For some reason it doesn't work!!! any help would be appreciated!!! thx