-2

The title says it all. Right now if I input a number like 100.50, in my program it prints as 100.5. Is there an easy way to make the program recognize the zero?

homidhomi4
  • 113
  • 11
  • 1
    It's the same number. What you want is string handling (i.e. representations of numbers). You would need to describe in more detail what you want - do you want to keep the input representation, or always format to two decimal digits, or...? – Amadan Oct 21 '15 at 02:07
  • If I recall, you capitalize the first letter of each word in a title, correct? Thanks for the input but GAVD answered my question – homidhomi4 Oct 21 '15 at 02:09

1 Answers1

1

You can do this trick.

String s = String.format("%.2f", 100.50);
GAVD
  • 1,977
  • 3
  • 22
  • 40