2018-11-09
public class TestIf { public static void main(String[]args) { double d=Math.random();//返回0-1之间的随机数每次都不同 System.out.println(d); int h= (int) (6*Math.random()+1);//不加1 是1-5 加1是1-6之间的数字 System.out.println(h); if(h<3) { System.out.println("小"); }else { System.out.println("大"); } System.out.println("###############################"); int a=(int) (6*Math.random()+1); System.out.println("a数字是"+a); int b=(int)(6*Math.random()+1); System.out.println("b数字是"+b); int c=(int)(6*Math.random()+1); System.out.println("c的数字是"+c); int count=a+b+c; System.out.println("摇到了"+count); if(count>15) { System.out.println("今天运气不错摇到了大于15\t"+count); } if(count<10) { System.out.println("今天运气不错摇到了小于10\t"+count); } if(count>=9&&count<=15) { System.out.println("今天运气不错摇到了\t"+count); } }