返回列表 發帖
本帖最後由 余映均 於 2019-8-6 14:39 編輯
  1. public class Ch02 {

  2.         public static void main(String[] args) {
  3.         String title[]={"座號","姓名","國文","英文","數學","平均"};
  4.         String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
  5.         int score[][]={{98,65,48},
  6.                                {97,85,96},
  7.                                {84,95,75},
  8.                                {65,85,60},
  9.                                {89,92,95}};
  10.         int avg;
  11.         for(int i=0;i<6;i++)
  12.             System.out.print(title[i]+"\t");
  13.         System.out.println();
  14.         System.out.println("==============================================");
  15.         for(int i=0;i<5;i++)
  16.         {
  17.                 avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
  18.                 System.out.print((i+1)+"\t"+name[i]+"\t");
  19.                 for(int j=0;j<3;j++)
  20.                     System.out.print(score[i][j]+"\t");
  21.                 System.out.println(avg);
  22.         }         
  23.         }
  24. }
複製代碼

TOP

返回列表