返回列表 發帖
  1. import java.util.Arrays;
  2. import java.util.Scanner;

  3. public class Ch05
  4. {
  5.   public static void main(String args[]){
  6.         String title[]={"Role","Name","Mand.","Engl.","Math","Avg."};
  7.     String name[]={"Bobs","Jenn","Samy","Bart","Rose"};
  8.   int score[][]={{78,89,66},
  9.                          {87,93,69},
  10.                          {62,50,75},
  11.                          {28,98,41},
  12.                          {92,97,89}};
  13.   int avg;
  14.   for(int i=0; i<6; i++)
  15.           System.out.print(title[i]+"\t");
  16.   System.out.println();System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  17.   for(int i=0; i<5; i++)
  18.   {
  19.           System.out.print((i+1)+"\t"+name[i]+"\t");
  20.           for(int j=0; j<3; j++)
  21.           {
  22.                 System.out.print(score[i][j]+"\t");
  23.           }
  24.           avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
  25.                 System.out.println(avg);
  26.   }
  27. }
  28. }
複製代碼

TOP

返回列表