| | |
array
![]() |
•
•
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 23 Days Ago
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
- 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#)
- How can is see what button is pressed in a button array (VB.NET)
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 |
2dgraphics account android api apple applet application array arrays automation banking bidirectional binary binarytree birt bluetooth chat chatprogramusingobjects class client code columns component database derby design designadrawingapplicationusingjavajslider eclipse encryption error errors expand fractal game givemetehcodez graphics gui homework html ide if_statement image inheritance integer intellij interface j2me java javadesktopapplications javaprojects jlabel jme jni jpanel jtextfield julia linux list map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring netbeans newbie nullpointerexception open-source problem program programming project property recursion reference ria scanner search server set sms sort sourcelabs splash sql sqlite static stop string subclass support swing testautomation threads tree ui unicode validation windows






