Not getting the values I want when I test my code.
Tried applying .2 to my %lf's and changing to doubles or floats.
#include <stdio.h>
int main (void){
double hours;
float grossPay;
double netPay;
const double rate = 7.25;
double federal;
double state;
float fica;
double medicare;
double deductions;
printf("Please enter hours worked per week: ");
scanf("%lf", &hours);
grossPay = hours * rate;
//calculated pay from input
printf("Hours per Week: %.2lf\n", hours);
printf("Hourly Rate: $%.2lf\n", rate);
printf("Gross Pay: $%.2lf\n", grossPay);
//calculations for deductions
federal = grossPay * 0.10;
state = grossPay * 0.014;
fica = grossPay * 0.062;
medicare = grossPay * 0.0145;
deductions = federal + state + fica + medicare;
netPay = grossPay - deductions;
printf("Net Pay: %lf\n\n", netPay);
printf("Deductions\n");
printf("Federal: $%lf\n", federal);
printf("State: $%lf\n", state);
printf("FICA: $%1.2lf\n", fica);
printf("Medicare: $%lf\n", medicare);
return 0;
}
My desired outputs are when I enter 30 for hours, the deductions should correspond with $21.75 $3.05 $13.49 $3.15 , with a net pay of $176.06
edit the values I was getting with 30 hours was $21.75, $3.04, $13.48, $3.15 if I used %.2lf