A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Random number problem
Joined: Oct 21, 2012
Nov 09, 2012 17:40:45
Hi, is there a way of generating a random number of type double from -500 to 500 using the import random class?
Joined: Sep 18, 2000
Nov 09, 2012 18:37:54
assuming you are using
7 (if not change 7 to the version you are using) and google 'java Random api 7'.
After reading the API you should find that......
First of all the class is
Second there is a method that will return a type you want, but the range needs to be changed.
And how do you change a numeric range? Well to make the range wider or small you could multiply by some factor.
And to change the base (i.e.: the lowest part of the range) to some number you could add (or subtract) some number.
Hope this helps
Oh by the way, the answer to the question you asked was a simple - yes.
Joined: Oct 13, 2005
Nov 10, 2012 03:19:19
If you use
, you have a method which makes that whole procedure simpler.
I agree. Here's the link:
subject: Random number problem
Does Sun changes test questions every month.those who have appeared, pl. reply.
WA #1.....word association
expense on conveyance...
Random number generation starting from and between
Minimum and maximum random number?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014