- public class Ch01{
- public static void main(String args[])
- {
- String title[]={"座號","姓名","國文","英文","數學","平均"};
- String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
- int score[][]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
- for(int i=0; i<=5; i++)
- System.out.print(title[i]+"\t");
- System.out.print("\n===============================================\n");
- for(int i=0; i<=4; i++)
- {
- float avg;
- avg=(score[i][0]+score[i][1]+score[i][2])/3;
- avg=Math.round(avg);
- System.out.print(i+1+"\t"+name[i]+"\t");
- for(int j=0; j<=2; j++)
- System.out.print(score[i][j]+"\t");
- System.out.println((int)avg);
- }
- }
- }
複製代碼 |