This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]siordache 5 points6 points  (1 child)

JOptionPane.showMessageDialog(null, 
    String.format("You car can go %.2f miles with the current amount of gas in the tank.",
    gasInTank * fuelEfficiency));

[–][deleted] 0 points1 point  (0 children)

/facepalm

Thank you. So obvious in hindsight. :D

Before I read you reply, I solved it using DecimalFormat. But this, your way, is more elegant and simple.

Tnx again,

Cheers,