java 计算中间值

来源:百度知道 编辑:UC知道 时间:2024/05/14 10:53:44
如何用java编写10到20的中间值?

import java.util.Random;

public class JavaMiddle {

/**
* @param args
*/
public static void main(String[] args) {
Random rand=new Random();
double middleValue=(rand.nextDouble()+1)*10;
System.out.println("Value is between 10 and 20 :\n"+middleValue);
}

}

10和20之间的数字 ....中间值....

祝楼主早日成功!

import java.util.Random;
public class Test
{
public static void main(String[] args)
{
double num=Random()*10+10;
System.out.println(num);
}
}

public class Test
{
public static void main(String[] args)
{

double rand=Math.random()*10+10;
System.out.println(rand);
}

}

good luck to you!