Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

# Thread: URGENT - Format a double?

1. ## URGENT - Format a double?

ok its 1:36AM and ive got to finish this last tiny thing.

So ive done the calculations, now the times are 9AM - 5PM where u enter an int in the apropreite time/day.

Clicking calculate will show the weekly average which is a double

When im finding the average of all the weekly averages put together it displays for example:

13.666666666666666

how do i format it to only show 13.6 ?

code:
// WEEK ROW 10 AVERAGE
double totalJ = weekA + weekB + weekC + weekD + weekE + weekF + weekG + weekH + weekI;
txtBox[69].setText(Double.toString(totalJ));

// WEEK ROW 11 AVERAGE

double doubleK = totalJ / 9;
txtBox[76].setText(Double.toString(doubleK));

ok thanks

2. ## Re: URGENT - Format a double?

meh fixed it the fix for this was:

// WEEK ROW 11 AVERAGE

double doubleK = totalJ / 9;
DecimalFormat decimalFormat = new DecimalFormat("#.##");
txtBox[76].setText(decimalFormat.format(doubleK));

Thread marked as solved.