Skip to main content

[Java]今天我們還是學Java

第二堂課,認真的Mr.Allen洋洋灑灑的做了24page的PowerPoint......
看來我這個學生想要偷懶是難如登天了!!!
為了不辜負Mr.Allen的苦心
我也是起了一個大早
從10點半就開始上課(天阿我大學的課都沒這麼準時耶~)

筆記:if, switch,while,for,break,out的用法

Homework如下:





import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class dice {

public static void main(String[] args) throws IOException {dowhile();}

public static void  dowhile() throws IOException
{
int k;

do
{
   BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
       System.out.print("請輸入數字: ");
       int i=Integer.parseInt(buf.readLine());
     
       double j =  Math.random()*6;
       int jj  = (int) j;
       while(jj<1 | jj>6)
       {
        System.out.println("電腦 " + jj);
        System.out.println("電腦秀斗,再試一次");
        j =  Math.random()*6;
        jj = (int) j;
     
       }
     
       double l =  Math.random()*6;
       int ll  = (int) l;
       while(ll<1 | ll>6)
       {
        System.out.println("電腦 " + ll);
        System.out.println("電腦秀斗,再試一次");
        l =  Math.random()*6;
        ll = (int) j;
     
       }
     
       double m =  Math.random()*6;
       int mm  = (int) m;
       while(mm<1 | mm>6)
       {
        System.out.println("電腦 " + mm);
        System.out.println("電腦秀斗,再試一次");
        m =  Math.random()*6;
        mm = (int) j;
     
       }
     
       int tt = jj+ll+mm;
     

       System.out.println("電腦一: " + jj +"電腦二: " + ll +"電腦三: " + mm);
                System.out.println("總合:"+ tt);
     
if(3>i | i>18)
{
System.out.print("ㄟ!你亂猜喔!!");
}

else if(i==tt)
{
       System.out.print("睹神說數字為:"+i);
       System.out.print("電腦說數字為:"+tt);
       System.out.print("My God ~ 你真的是睹神 ! ! ");
}

 System.out.println("\n你不是睹神.....>_<... ");
 System.out.println("再猜一次(繼續1 結束0) ");
      BufferedReader buf2 = new BufferedReader(new InputStreamReader(System.in));
       k=Integer.parseInt(buf2.readLine());

  }while(k==1);

 }
}


哈哈哈!!看出來了嗎?
明年過年大家有好玩的了!!!

Comments

Popular posts from this blog

[First Kick] I'm proud of you

因為歐喔一直很愛球 所以今年兩歲生日時我送了她一顆手工足球 (熊貓可是她指定的動物) 買球時剛好找到這家有訓練幼兒的球類運動中心 身為父母的我們簡直如獲至寶 心理打著「要是可以讓歐喔定期來這裏放電那就太好了!」的如意算盤 立刻就報名了試讀課程 而今天 歐喔的表現真是讓我好欣慰又好驕傲!

Birthday

John John John John~!!!! New Blog is arrived. This is the blog belongs to us only and first. First time, we share our thinking not just via talking and drinking. First time, we do the same thing not just watch Friends or Two and the Half man. First time, we have our baby; it is not a human being though.