So if I have the float variable interval
and I want to print it, I want it to print with all of the necessary figures and no extra.
If I use System.out.printf("%f", interval);
where float interval = 15
I get an output of 15.000000
.
I can fix that by using System.out.printf("%2.0f", interval)
to which I get an output of 15
, but if I do that then where float interval = 12.05f
I get an output of 12
.
My assignment requires me to use printf().