哈哈,问题答案验证应该是开发一点的,有点死板哈~
public class HelloWorld { static String clsssNum = "2班"; static double avSum = 0; static int[] cols = {67,78,98,56,88,34,89}; public static int avScore(){ for(int i=0; i<HelloWorld.cols.length; i++){ HelloWorld.avSum += HelloWorld.cols[i]; } return (int)HelloWorld.avSum/HelloWorld.cols.length; } public static void main(String[] args){ HelloWorld test = new HelloWorld(); System.out.println(HelloWorld.clsssNum+"学生的平均成绩是"+test.avScore()); } }