import java.io.* ; public class ExamResult1 { public ExamResult1() { } public static void main(String args[]) { int total = 0 ; int average = 0 ; int stuResult[] = new int[31] ; int stuNumber[] = new int[31] ; String stuName[] = {"","jason" ,"kitty" ,"Ken","San","King", "David","Jerry","Heary","Abs","Coll", "LI","Zhang","Kiki","KAKA","COCO", "Paul","mC","Wade","Nice","Fore", "Opio","Kiss","Kirt","Kurt","Coke", "Frant","OL","eYE","Joe","KK"} ; System.out.println("NAME\t学号\t成绩") ; for (int count = 1 ; count <= 31 ; count++) { stuResult[count] = 1 + (int)(Math.random() * 100 ) ; stuNumber[count] = count ; System.out.println(stuName[count] + "\t" + stuNumber[count] + "\t" + stuResult[count]) ; total += stuResult[count] ; } average = total/30 ; System.out.print("总成绩为" + total); System.out.print("平均成绩为" + average); } }
可以打印出来成绩,学号和姓名,但是打印不出总成绩和平均成绩 。