944,116 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 305
  • Java RSS
Nov 3rd, 2009
0

array

Expand Post »
i have a question but am confuse
the question is create and array of random double floating point numbers,calculate and print the sum off all the numbers in the array.truncates all of the numbers in the array up to 7 decimal places and then calculate and print the sum of the truncated numbers.calculate and print the difference between the actual sum of the numbersand the sum of the truncated numbers.the part i understand was how to
then you can use the java.text.NumberFormat class.

double value = 5.9999999999999;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(7);
String displayValue = nf.format(value);
System.out.println(displayValue);

//should print >5.9999999
but i dont kbnow haw to create a random double floating point numbers it just confuse me ,can someon help me out?please
Similar Threads
Reputation Points: 6
Solved Threads: 0
Light Poster
asong is offline Offline
30 posts
since Oct 2009
Nov 3rd, 2009
0
Re: array
What is the range of the random numbers? Because you can use the Math.random.
Check the API
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 447
Nearly a Senior Poster
javaAddict is offline Offline
3,260 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Dumb NetBeans IDE question: I've lost my palette!
Next Thread in Java Forum Timeline: Hibernate HBM with many <class> tags





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC