- Apr 15 Mon 2019 19:59
-
2019.04 請用二維陣列計算成績
- Apr 14 Sun 2019 13:24
-
2019.04 網頁影片練習
- Apr 10 Wed 2019 17:59
-
我想你不應該當一個公車司機(一)制度面
- Mar 29 Fri 2019 11:20
-
2019.03 數字轉大寫
package ch7;
import java.io.*;
public class ch7_10_2
{
public static void main(String awgs[]) throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
String n[]= {"零","壹","貳","參","肆","伍","陸","柒","哵","玖"};
String sn;
int num=4321,a,b,c,d=1;
System.out.println("請輸入九位以下數字");
sn=buf.readLine();
num=Integer.parseInt(sn);
b=100000000;
sn="";
c=num;
a=c;
do
{
a=num;
c=a%b;
num=c;
a=(a-c)/b;
if(a==0)
{
if(d==0)
{
sn=sn.concat(n[0]);
d++;
}
}
else
{
d=0;
}
if (d==0)
{
sn=sn.concat(n[a]);
switch (b)
{
case 0:
break;
case 10:
sn=sn.concat("拾");
break;
case 100:
sn=sn.concat("佰");
break;
case 1000:
sn=sn.concat("仟");
break;
case 10000:
sn=sn.concat("萬");
break;
case 100000:
sn=sn.concat("拾");
break;
case 1000000:
sn=sn.concat("佰");
break;
case 10000000:
sn=sn.concat("仟");
break;
case 100000000:
sn=sn.concat("億");
break;
}
}
else
{
if(b==10000)
{
sn=sn.concat("萬");
}
}
b=b/10;
}while(b!=0);
System.out.print("金額是"+sn);
}
import java.io.*;
public class ch7_10_2
{
public static void main(String awgs[]) throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
String n[]= {"零","壹","貳","參","肆","伍","陸","柒","哵","玖"};
String sn;
int num=4321,a,b,c,d=1;
System.out.println("請輸入九位以下數字");
sn=buf.readLine();
num=Integer.parseInt(sn);
b=100000000;
sn="";
c=num;
a=c;
do
{
a=num;
c=a%b;
num=c;
a=(a-c)/b;
if(a==0)
{
if(d==0)
{
sn=sn.concat(n[0]);
d++;
}
}
else
{
d=0;
}
if (d==0)
{
sn=sn.concat(n[a]);
switch (b)
{
case 0:
break;
case 10:
sn=sn.concat("拾");
break;
case 100:
sn=sn.concat("佰");
break;
case 1000:
sn=sn.concat("仟");
break;
case 10000:
sn=sn.concat("萬");
break;
case 100000:
sn=sn.concat("拾");
break;
case 1000000:
sn=sn.concat("佰");
break;
case 10000000:
sn=sn.concat("仟");
break;
case 100000000:
sn=sn.concat("億");
break;
}
}
else
{
if(b==10000)
{
sn=sn.concat("萬");
}
}
b=b/10;
}while(b!=0);
System.out.print("金額是"+sn);
}
- Mar 28 Thu 2019 22:53
-
2019.03 輸入星期幾
package ch7;
import java.io.*;
public class ch7_10_1
{
public static void main(String awgs[]) throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
String s[]= {"一","二","三","四","五","六","日"};
String ent;
int a;
ent=buf.readLine();
a=Integer.parseInt(ent);
if (a>=0 & a<=6)
{
System.out.print("星期"+s[a]);
}
else
{
System.out.print("只可以輸入0~6");
}
}
import java.io.*;
public class ch7_10_1
{
public static void main(String awgs[]) throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
String s[]= {"一","二","三","四","五","六","日"};
String ent;
int a;
ent=buf.readLine();
a=Integer.parseInt(ent);
if (a>=0 & a<=6)
{
System.out.print("星期"+s[a]);
}
else
{
System.out.print("只可以輸入0~6");
}
}
- Mar 28 Thu 2019 11:37
-
2019.03 金魚腦P3
- Mar 27 Wed 2019 14:27
-
2019.03 金魚腦P2
<!DOCTYPE html>
<html lang="zh-hant-TW">
<head>
<meta charset="UTF-8">
<title>金魚2</title>
<style type="text/css">
.amos{
background-color: #f00;
<html lang="zh-hant-TW">
<head>
<meta charset="UTF-8">
<title>金魚2</title>
<style type="text/css">
.amos{
background-color: #f00;
- Mar 27 Wed 2019 11:53
-
2019.03 金魚腦練習
- Mar 23 Sat 2019 22:28
-
2019.03 對樂透號碼和獎項
package ch7;
public class ch7_9
{
public static void main(String awgs[])
{
int bun[]= {2,3,22,28,29,30,39};
int h1[]= {2,3,22,28,29,39};
int r1[]=new int[6];
int a=0,b=0,c=0,d=0,e=0;
for(a=0;a<=5;a++)
{
r1[a]=(int)(Math.random()*39)+1;
}
for(a=0;a<=4;a++)
{
for(b=0;b<=4;b++)
{
if(r1[b]>r1[b+1])
{
c=r1[b+1];
r1[b+1]=r1[b];
r1[b]=c;
}
}
}
for(a=0;a<=5;a++)
{
System.out.print(r1[a]+",");
}
System.out.println();
c=0;
for(a=0;a<=6;a++)
{
if (a==6)
{
if(h1[c]==bun[a])
{
e=e+1;
}
}
else
{
if(h1[c]==bun[a])
{
d=d+1;
}
if(h1[c]<=bun[a])
{
c=c+1;
}
}
}
System.out.println("小名中了什麼獎呢?");
if(e==1)
{
if(d==5)
{
System.out.println("中了五個號碼加特別號!二獎!");
}
}
else
{
switch (d)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
case 5:
System.out.println("中了五個號碼!三獎!");
break;
case 6:
System.out.println("中了六個號碼!頭獎!");
break;
}
}
a=0;
b=0;
c=0;
d=0;
e=0;
for(a=0;a<=6;a++)
{
if (a==6)
{
if(r1[c]==bun[a])
{
e=e+1;
}
}
else
{
if(r1[c]==bun[a])
{
d=d+1;
}
if(r1[c]<=bun[a])
{
c=c+1;
}
}
}
System.out.println("小王中了什麼獎呢?");
if(e==1)
{
if(d==5)
{
System.out.println("中了五個號碼加特別號!二獎!");
}
switch (d)
{
case 0:
System.out.println("沒中");
break;
case 1:
System.out.println("沒中!");
break;
case 2:
System.out.println("沒中!!");
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
}
}
else
{
switch (d)
{
case 0:
System.out.println("沒中");
break;
case 1:
System.out.println("沒中!");
break;
case 2:
System.out.println("沒中!!");
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
case 5:
System.out.println("中了五個號碼!三獎!");
break;
case 6:
System.out.println("中了六個號碼!頭獎!");
break;
}
}
}
}
public class ch7_9
{
public static void main(String awgs[])
{
int bun[]= {2,3,22,28,29,30,39};
int h1[]= {2,3,22,28,29,39};
int r1[]=new int[6];
int a=0,b=0,c=0,d=0,e=0;
for(a=0;a<=5;a++)
{
r1[a]=(int)(Math.random()*39)+1;
}
for(a=0;a<=4;a++)
{
for(b=0;b<=4;b++)
{
if(r1[b]>r1[b+1])
{
c=r1[b+1];
r1[b+1]=r1[b];
r1[b]=c;
}
}
}
for(a=0;a<=5;a++)
{
System.out.print(r1[a]+",");
}
System.out.println();
c=0;
for(a=0;a<=6;a++)
{
if (a==6)
{
if(h1[c]==bun[a])
{
e=e+1;
}
}
else
{
if(h1[c]==bun[a])
{
d=d+1;
}
if(h1[c]<=bun[a])
{
c=c+1;
}
}
}
System.out.println("小名中了什麼獎呢?");
if(e==1)
{
if(d==5)
{
System.out.println("中了五個號碼加特別號!二獎!");
}
}
else
{
switch (d)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
case 5:
System.out.println("中了五個號碼!三獎!");
break;
case 6:
System.out.println("中了六個號碼!頭獎!");
break;
}
}
a=0;
b=0;
c=0;
d=0;
e=0;
for(a=0;a<=6;a++)
{
if (a==6)
{
if(r1[c]==bun[a])
{
e=e+1;
}
}
else
{
if(r1[c]==bun[a])
{
d=d+1;
}
if(r1[c]<=bun[a])
{
c=c+1;
}
}
}
System.out.println("小王中了什麼獎呢?");
if(e==1)
{
if(d==5)
{
System.out.println("中了五個號碼加特別號!二獎!");
}
switch (d)
{
case 0:
System.out.println("沒中");
break;
case 1:
System.out.println("沒中!");
break;
case 2:
System.out.println("沒中!!");
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
}
}
else
{
switch (d)
{
case 0:
System.out.println("沒中");
break;
case 1:
System.out.println("沒中!");
break;
case 2:
System.out.println("沒中!!");
break;
case 3:
System.out.println("中了三個號碼!五獎!");
break;
case 4:
System.out.println("中了四個號碼!四獎!");
break;
case 5:
System.out.println("中了五個號碼!三獎!");
break;
case 6:
System.out.println("中了六個號碼!頭獎!");
break;
}
}
}
}
- Mar 22 Fri 2019 17:31
-
2019.03 依序輸入資料並可查詢
package ch7;
import java.io.*;
public class ch7_7
{
public static void main(String args[])throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
int num[]=new int[50];
int x,a=0,b,c;
String sc;
for (x=0;x<=49;x++)
{
num[x]=0;
}
x=0;
do
{
System.out.println("please type a number,-1 for leave the part");
sc=buf.readLine();
c=Integer.parseInt(sc);
num[x]=c;
x++;
}while(num[x-1]!=-1);
do
{
System.out.println("search the data 1~"+(x-1));
sc=buf.readLine();
c=Integer.parseInt(sc);
System.out.println("data "+c+" is "+num[c-1]);
}while(a<=10);
}
}
import java.io.*;
public class ch7_7
{
public static void main(String args[])throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
int num[]=new int[50];
int x,a=0,b,c;
String sc;
for (x=0;x<=49;x++)
{
num[x]=0;
}
x=0;
do
{
System.out.println("please type a number,-1 for leave the part");
sc=buf.readLine();
c=Integer.parseInt(sc);
num[x]=c;
x++;
}while(num[x-1]!=-1);
do
{
System.out.println("search the data 1~"+(x-1));
sc=buf.readLine();
c=Integer.parseInt(sc);
System.out.println("data "+c+" is "+num[c-1]);
}while(a<=10);
}
}
- Mar 22 Fri 2019 17:15
-
2019.03 查詢有沒有到
package ch7;
import java.io.*;
public class ch7_5_2
{
public static void main(String awgs[])throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
int num[]=new int[12];
int x,a,b=0,c;
String sc;
for (x=0;x<=11;x++)
{
num[x]=(int)(Math.random()*2);
System.out.print(num[x]+",");
}
System.out.println();
do
{
System.out.println("Enter the number u wanna check 1~12");
sc=buf.readLine();
c=Integer.parseInt(sc);
c=c-1;
if (num[c]>0)
{
System.out.println((c+1)+" is here");
}
else
{
System.out.println((c+1)+" not here");
}
}while(b<=10);
}
}
import java.io.*;
public class ch7_5_2
{
public static void main(String awgs[])throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
int num[]=new int[12];
int x,a,b=0,c;
String sc;
for (x=0;x<=11;x++)
{
num[x]=(int)(Math.random()*2);
System.out.print(num[x]+",");
}
System.out.println();
do
{
System.out.println("Enter the number u wanna check 1~12");
sc=buf.readLine();
c=Integer.parseInt(sc);
c=c-1;
if (num[c]>0)
{
System.out.println((c+1)+" is here");
}
else
{
System.out.println((c+1)+" not here");
}
}while(b<=10);
}
}
- Mar 22 Fri 2019 16:59
-
2019.03 練習陣列
package ch7;
public class ch7_5_2
{
public static void main(String awgs[])
{
int x,n=0,p=0,n0=0;
int [][][][]a=new int[10][2][4][5];
int number [ ]={-1,0,3,4,-5,8};
for (x=0;x<=6;x++)
{
if(number[x]<=0)
{
if(number[x]==0)
{
n0++;
}
else
{
n++;
}
}
else
{
p++;
}
}
System.out.print(n0+" for 0 , "+p+" for positive "+n+" for negative");
}
public class ch7_5_2
{
public static void main(String awgs[])
{
int x,n=0,p=0,n0=0;
int [][][][]a=new int[10][2][4][5];
int number [ ]={-1,0,3,4,-5,8};
for (x=0;x<=6;x++)
{
if(number[x]<=0)
{
if(number[x]==0)
{
n0++;
}
else
{
n++;
}
}
else
{
p++;
}
}
System.out.print(n0+" for 0 , "+p+" for positive "+n+" for negative");
}