第二堂課,認真的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);
}
}
看來我這個學生想要偷懶是難如登天了!!!
為了不辜負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
Post a Comment