dimanche 5 décembre 2021

Generate random doubles between 0 and 1000 in Java

I am working on an assignment for my Java class and I am having trouble generating a random dollar amount. I need the value to be a double between 0 and 1000 (for example, 561.64 or 968.42). nextDouble() only produces values between 0.0 and 1.0. I'm not having any luck searching here or on Google. Can anybody point me in the right direction? I am trying to use the SecureRandom class because that what we've used in other exercises, but I could probably use a different method if there's a good reason.




Aucun commentaire:

Enregistrer un commentaire