import java.text.DecimalFormat;
import java.util.Random;
public class Mathtest{
public static void main(String[] args) {
Double d=Math.random();//产生一个随机数d
DecimalFormat df=new DecimalFormat("########.###");//设置一个固定格式为“0.xxx”
String ddString=df.format(d);//将d转换为“0.xxx”的格式,并转换为字符串类型
double dou=Double.parseDouble(ddString);//将String类型的变量ddString转换成double型的dou
Random random=new Random();
dou=dou+random.nextInt(200);//取值范围在0~~200之间
System.out.println(Math.ceil(dou));
System.out.println(Math.floor(dou));
System.out.println(Math.sqrt(dou));
}
}
//转自https://wenku.baidu.com/view/68fde8252af90242a895e5f9.html