請用二維陣列
計算每人總分和平均

驢子 發表在 痞客邦 留言(0) 人氣()

https://drive.google.com/open?id=1wJ_HShSs54nILF2NW-Wx0LsbldCEXyEs
 

驢子 發表在 痞客邦 留言(0) 人氣()

學習開公車前你也許知道的事情
 

驢子 發表在 痞客邦 留言(0) 人氣()

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);
    }

驢子 發表在 痞客邦 留言(0) 人氣()

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");
        }
    }

驢子 發表在 痞客邦 留言(0) 人氣()

需要搭配檔案才能使用
 

驢子 發表在 痞客邦 留言(0) 人氣()

<!DOCTYPE html>
<html lang="zh-hant-TW">
<head>
    <meta charset="UTF-8">
    <title>金魚2</title>
    <style type="text/css">
        .amos{
            background-color: #f00;

驢子 發表在 痞客邦 留言(0) 人氣()

<!DOCTYPE html>
<html lang=zh-hant-TW>
<head>
    <meta charset="utf-8">
    <title>這邊是標籤文字</title>

驢子 發表在 痞客邦 留言(0) 人氣()

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;
            }
        }
    }
}
 

驢子 發表在 痞客邦 留言(0) 人氣()

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);
    }
}

驢子 發表在 痞客邦 留言(0) 人氣()

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);
    }
}
 

驢子 發表在 痞客邦 留言(0) 人氣()

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");
    }

驢子 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。