package javatext;
public class 骰子 {
public static void main (String[] args) {
double d = Math.random();//生成[0,1)的随机数
int a = (int)(Math.random()*6) + 1;//因为骰子的点数是[1,6],所以要加1,将doubl类型的数据强制转换为int类型数据。
int b = (int)(Math.random()*6) + 1;
int c = (int)(Math.random()*6) + 1;
int count = a + b + c;
if(count > 15) {
System.out.println("今天手气不错");
}
if(count>=10&&count>=15) {
System.out.println("运气一般");
}
if(count<=10) {
System.out.println("今天手气不怎么样");
}
System.out.println("得了"+ count +"分");
}
}
网友评论