- public class Ch10{
- public static void main(String[]args)
- {
- String title[]={"號","名","國","英","數","平均"};
- String name[]={"a","s","d","f","g","h"};
- int score[][]={{90,88,89},
- {70,67,54},
- {89,88,90},
- {17,33,56},
- {77,79,46}};
- for(int i=0; i<6;i++)
- System.out.print(title[i]+"\t");
- System.out.println("\n=============================================");
- 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 avg=(float)(score[i][0]+score[i][1]+score[i][2])/3;
- System.out.println(avg);
- }
- }
- }
複製代碼 |