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 <= 30 ; 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); } }
这个问题如果用OOP做,定义一个student的类,该怎么弄啊,我没有头绪,请大家指点,谢谢!