English 中文(简体)
我如何随机产生75-100%的数字?
原标题:How do I randomly generate a number between 75 - 100%?

我知道如何在0到100之间做到这一点,但我可以发言吗?

这就是我是如何做的。

int randomNum = (int) Math.ceil(Math.random() * 100);
最佳回答

随机数量从0到25,增加75。

问题回答
int randomNum = (int) Math.ceil(Math.random() * 25) + 75;

零到25岁,然后增加75人。

是否在零到25之间,增加75。

我知道这一点已经得到了回答,但正确的答案没有准则。 因此,这里是一部小的法典:

int randomNum = 0;
Random ran = new Random();
randomNum  = ran.nextInt(25) + 75;




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签