| | |
array
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 4
Reputation:
Solved Threads: 0
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
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
0
#2 Nov 3rd, 2009
What is the range of the random numbers? Because you can use the Math.random.
Check the API
Check the API
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- How can is see what button is pressed in a button array (VB.NET)
- Printing a histogram from a frequency array (C)
- troubleshoot char array; (C++)
- Dynamic array => dropdown issues... (PHP)
- passing a pointer/reference to array into a class (C#)
Other Threads in the Java Forum
- Previous Thread: Dumb NetBeans IDE question: I've lost my palette!
- Next Thread: Hibernate HBM with many <class> tags
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth businessintelligence chat class classes client code component database desktop draw ebook eclipse encode equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop mac main map method methods mobile netbeans newbie number object online open-source oracle parameter print problem program programming project properties recursion reference replaysolutions rotatetext scanner score screen scrollbar server set size sms socket sort sql string superclass swing template test threads time tree windows xstream






