本帖最後由 張郁庭 於 2019-8-6 14:16 編輯
- public class Ch01
- {
- public static void main(String args[])
- {
- String title[]={"座號","姓名","國文","英文","數學","平均"};
- String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
- int score[][]={{84,95,78,0},
- {84,62,75,0},
- {75,65,84,0},
- {84,95,75,0},
- {64,65,74,89}};
- for(int i=0; i<6; i++)
- System.out.print(title[i]+"\t");
- System.out.println();
- System.out.println("===========================================");
- for(int i=0; i<5; i++)
- {
- System.out.print((i+1)+"\t"+name[i]+"\t");
- for(int j=0; j<3; j++)
- {
- System.out.print(score[i][j]+"\t");
- }
- float average=(float)((score[i][0]+score[i][1]+score[i][2])/3);
- System.out.println(Math.round(average));
- }
- }
- }
複製代碼 |