Java decimal format shows up as .00

mossman

Gawd
Joined
Feb 10, 2002
Messages
664
I'm got three int that I want to find the average of, So I divide by 3 and used

Code:
DecimalFormat twoDigits= new DecimalFormat("0.00");

When I divide the ints by three I am getting a double but it only shows up like 59.00 or 74.00, when the 0's should have a decimal number.

I divided the numbers in my array like this:

Code:
averages[z][y] = (grades[z][y] + grades[z][y+1] + grades[z][y+2])/ 3;

Why is it showing up as .00 on the end? Is there a different method to divide ints that equal a double? thanks
 
divide by 3.0 instead of 3. you're doing integer division.
 
Back
Top