无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

if結(jié)構(gòu)使用

2022-06-03 17:08 作者:虛云幻仙  | 我要投稿

/**
* 測試if結(jié)構(gòu)與隨機(jī)數(shù)
* 擲三個骰子
* if(條件即布爾表達(dá)式){執(zhí)行內(nèi)容}
*/

public class TestIf01 {
? ?public static void main(String[] args) {
? ? ? ?double rand = Math.random();//Math中的random隨機(jī)生成0-1之間的浮點(diǎn)數(shù)
? ? ? ?System.out.println(rand);
? ? ? ?int rand1 = (int)(rand*6+1);
? ? ? ?System.out.println(rand1);
? ? ? ?int i = (int)(Math.random()*6+1);
? ? ? ?int j = (int)(Math.random()*6+1);
? ? ? ?int k = (int)(Math.random()*6+1);
? ? ? ?if(i+j+k>15){
? ? ? ? ? ?System.out.println("手氣不錯");
? ? ? ?} else if (i+j+k>10) {
? ? ? ? ? ?//不滿足>15時繼續(xù)判定是否>10
? ? ? ? ? ?System.out.println("一般");
? ? ? ?}else {
? ? ? ? ? ?//上面條件均false執(zhí)行else的語句塊
? ? ? ? ? ?System.out.println("手氣不佳");
? ? ? ?}
? ? ? ?System.out.println("總點(diǎn)數(shù):"+(i+j+k));

? ? ? ?double r = 4*Math.random();
? ? ? ?double area1 = Math.PI*r*r;//Math中的PI指圓周率
? ? ? ?double a1 = 12*Math.random();
? ? ? ?double a2 = 4*Math.random();
? ? ? ?double area2 = a1*a2;
? ? ? ?double a3 = area1>area2?area1:area2;//條件運(yùn)算符和if同理
? ? ? ?System.out.println(a3);

? ? ? ?int age = (int)(120*Math.random());
? ? ? ?System.out.println("年齡是:"+age);
? ? ? ?if(age<18){
? ? ? ? ? ?System.out.println("未成年");
? ? ? ?} else if (age<=35) {
? ? ? ? ? ?System.out.println("輕年");
? ? ? ?} else if (age<=50) {
? ? ? ? ? ?System.out.println("中年");
? ? ? ?} else if (age<=84) {
? ? ? ? ? ?System.out.println("老年");
? ? ? ?}else {
? ? ? ? ? ?System.out.println("壽星");
? ? ? ?}
? ?}
}

if結(jié)構(gòu)使用的評論 (共 條)

分享到微博請遵守國家法律
武城县| 汉沽区| 靖州| 卢氏县| 昌黎县| 阳新县| 买车| 响水县| 资阳市| 泾阳县| 巢湖市| 新津县| 临泽县| 阿克| 河北省| 盱眙县| 海口市| 会东县| 赤水市| 蒲城县| 双江| 沛县| 东平县| 平泉县| 南投县| 绍兴县| 高雄县| 永清县| 古田县| 蒙城县| 康乐县| 碌曲县| 铜川市| 阜康市| 报价| 海林市| 泸定县| 吴旗县| 榆林市| 香港 | 泊头市|