| | |
request and question in float random number
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2007
Posts: 63
Reputation:
Solved Threads: 0
Hi guys hope you fine
I have a request and question, for my request I would like from you to recommend me
which books and tutorials that I may follow help me to understand how to read and write files in java I really need to know that. and for my question is how to make a float random ends with five or zero only. For example 0.25 , 0.30 , 0.35 , 0.40 , 0.45 ,0.50 , 0.55 , and so on till number one. I don't need a float numbet appears to me such as 0.23 , 0.14 , 0.78 , 0.99 , 0.61 , 0.12 , etc ... so how it's done that
thanks,
my regard
I have a request and question, for my request I would like from you to recommend me
which books and tutorials that I may follow help me to understand how to read and write files in java I really need to know that. and for my question is how to make a float random ends with five or zero only. For example 0.25 , 0.30 , 0.35 , 0.40 , 0.45 ,0.50 , 0.55 , and so on till number one. I don't need a float numbet appears to me such as 0.23 , 0.14 , 0.78 , 0.99 , 0.61 , 0.12 , etc ... so how it's done that
thanks,
my regard
•
•
Join Date: Nov 2006
Posts: 224
Reputation:
Solved Threads: 31
how about you just store it as an integer which when divided by 20 yields your number?
--
Index of mp3
Index of mp3
I would do it as such. Assuming you want the floating number to be displayed to only 2dp.
So for example:-
7 / 10 = 0.7
0.05
0.7 + 0.05 = 0.75
- I would first, generate an integer between 1-9, then divide it by 10.
- Then I would have a second random function that generates either 0.05 or 0.0
- I would then add the two together.
So for example:-
7 / 10 = 0.7
0.05
0.7 + 0.05 = 0.75
Last edited by iamthwee; Dec 30th, 2007 at 12:31 pm.
*Voted best profile in the world*
![]() |
Other Threads in the Java Forum
- Previous Thread: i need help with GUI
- Next Thread: java.sql.SQLException: Invalid column index
Views: 882 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation bidirectional binary birt bluetooth calculator chat class classes client code columns component database designadrawingapplicationusingjavajslider detection draw eclipse editor error errors event exception expand file fractal game givemetehcodez graphics gui guidancer helpwithhomework html ide image inetaddress input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jme jmf jni jpanel julia linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie number object oracle os plazmic print problem program programming project recursion scanner screen server set signing size smart sms smsspam socket sort sql string subclass support swing test threads time transfer tree windows






