Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java code number formatting

843810Feb 27 2004 — edited Apr 3 2004
Wonder if you could help me, I am a student and I've written an applet program for an assignment that creates an array of objects, each object has 3 elements. A string, another string, and a float. The float is multiplied with an integer in another method, and the resulting outputs a number which is the price of a "book". I need to format that result to show two decimal places, but when there is only one number I just get that number instead of the zero, for example if the result is 42.50 I just get 42.5. How do I get that last zero to show up, could you show me an example line of code for this number formatting? Thanks.

Tyler
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2004
Added on Feb 27 2004
4 comments
137 views