0

hi, I'm trying to do my decimal to the nearest hundreths, i've tried using number format and printf but i couldn't do it. Anybody can help me with this: here is my program

```
float grossPay = (calcGross(nHrsWrkd, hrlyRate));
float netPay = (calcTaxes (calcGross (nHrsWrkd, hrlyRate)));
System.out.print("\nTaxes Withheld - $"
+ nf.format(calcTaxes (grossPay)) );
System.out.print("\nNet Pay - $" +
nf.format(grossPay - netPay));
static float calcTaxes(float grossPay)///calc of income tax
{
float netPay = 0 ;
final float x = 0.15f;
final float y = 0.20f;
final float z = 0.25f;
final float a = 300;
final float b = 450;
final float c = 451;
if (grossPay >= c)
netPay = (float)((z * (grossPay - b)) + (x * a) + (y * (b - a)));
if (grossPay <= b)
netPay = (float) (y *(grossPay - a) + (x * a));
else if (grossPay <= a)
netPay = (float) (grossPay - (grossPay * z));
return netPay ;
}
```

i'm trying to input the data like this

```
hrs work 52.50
hr rate 15.00
gross pay 881.25
```

output=

```
tax withheld = 182.812
net pay = 698.438
```

and i'm getting an output of more than 2 decimal place eventhough i applied the number format command

*Edited
by Dani*: Formatting fixed