Here's an example of displaying decimal value:
DecimalFormat twoDigits = new DecimalFormat( " 0.00" );
if ( gradeCounter != 0 ) {
average = total / gradeCounter;
// display output here
JOptionPane.showMessageDialog( null,
"Average is " + twoDigits.format( average ), " Average ",
JOptionPane.INFORMATION_MESSAGE );
}
the first statement declares twoDigits as a reference to an object of
class DecimalFormat.
DecimalFormat objects are used to format number. In this example we want
to output the variable average with two digits to the right of the decimal
point.
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---