- import java.util.Arrays;
- import java.util.Scanner;
- public class Ch05
- {
- public static void main(String args[]){
- String title[]={"Role","Name","Mand.","Engl.","Math","Avg."};
- String name[]={"Bobs","Jenn","Samy","Bart","Rose"};
- int score[][]={{78,89,66},
- {87,93,69},
- {62,50,75},
- {28,98,41},
- {92,97,89}};
- int avg;
- 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");
- }
- avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
- System.out.println(avg);
- }
- }
- }
複製代碼 |