| Author |
I am trying to only display at most two decimal digits.(rounding)
|
aleandro santos
Greenhorn
Joined: Feb 05, 2007
Posts: 1
|
|
I am writtng a java app that computes an energy bill, but the computations are only supposed to display two decimals digits at the most. here is my code, I am trying to find a way to only display the two digits after the decimal in the answer (print statement). I was thinking that I could use a string method or something.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
Hi, Welcome to JavaRanch! Have a look at the PrintStream.printf() method (i.e., System.out.printf() ). See the documentation here.
|
[Jess in Action][AskingGoodQuestions]
|
 |
John Bartlett
Ranch Hand
Joined: Jan 25, 2006
Posts: 116
|
|
Hi, You could also take a look at the BigDecimal class. Or take a look at the DecimalFormat class. John
|
 |
 |
|
|
subject: I am trying to only display at most two decimal digits.(rounding)
|
|
|