How do you round a decimal when using the if statement in Java?
String.format (“%.2f”, var); where var is your newBalance, etc.
This rounds it to 2 decimal place.
Based on your code,
System.out.println ("Interest: $" + String.format ("%.2f", interest);. Note that
% is a character used to indicate that the following are the formatting instructions.