import java.util.*;
public class 成绩管理系统 {
public static void main(String[] args){
Scanner c=new Scanner(System.in);
System.out.println("请输入学生的人数:");
int renshu=c.nextInt();
System.out.println("请输入课程的数目:");
int number=c.nextInt();
String[] course=new String[number];
String[] xuesheng=new String[renshu]; 
int[][] chengji=new int[renshu][number];
int[] s=new int[renshu];
int[] arg=new int[renshu];
String[] all=new String[renshu];
for(int i=0;i<number;i++){
System.out.println("请定义第"+(i+1)+"门课程是:");
course[i]=c.next();
}
for(int i=0;i<renshu;i++){
System.out.println("请定义第"+(i+1)+"位学生姓名为:");
xuesheng[i]=c.next();
int sum=0;
String all1="";
for(int j=0;j<number;i++){
System.out.println("请输入"+xuesheng[i]+course[j]+"的成绩:");
chengji[i][j]=c.nextInt();
sum+=chengji[i][j];
all1+=chengji[i][j]+"\t";
}
s[i]+=sum;
arg[i]=s[i]/number;
all[i]=xuesheng[i]+"\t"+all1+s[i]+"\t"+arg[i];
}
for(int i=0;i<xuesheng.length-1;i++){
for(int j=0;j<xuesheng.length-1;j++){
if(s[j]<s[j+1]){
int a=s[j];  String b=all[j];
s[j]=s[j+1]; all[j]=all[j+1];
s[j+1]=a;    all[j+1]=b;
}
}
}
System.out.print("学生"+"\t");
for(int i=0;i<course.length;i++){
System.out.print(course[i]+"\t");
}
System.out.println("总分\t平均分\t排行榜");
for(int i=0;i<xuesheng.length;i++){
System.out.println(all[i]+"\t第"+(i+1)+"名");
}
}
}

解决方案 »

  1.   

    public static void main(String[] args) throws IOException {
    Scanner c = new Scanner(System.in);
    System.out.println("请输入学生的人数:");
    int renshu = c.nextInt();
    System.out.println("请输入课程的数目:");
    int number = c.nextInt();
    String[] course = new String[number];
    String[] xuesheng = new String[renshu];
    int[][] chengji = new int[renshu][number];
    int[] s = new int[renshu];
    int[] arg = new int[renshu];
    String[] all = new String[renshu];
    for (int i = 0; i < number; i++) {
    System.out.println("请定义第" + (i + 1) + "门课程是:");
    course[i] = c.next();
    }
    for (int i = 0; i < renshu; i++) {
    System.out.println("请定义第" + (i + 1) + "位学生姓名为:");
    xuesheng[i] = c.next();
    int sum = 0;
    String all1 = "";
    for (int j = 0; j < number; j++) {
    System.out.println("请输入" + xuesheng[i] + course[j] + "的成绩:");
    chengji[i][j] = c.nextInt();
    sum += chengji[i][j];
    all1 += chengji[i][j] + "\t";
    }
    s[i] += sum;
    arg[i] = s[i] / number;
    all[i] = xuesheng[i] + "\t" + all1 + s[i] + "\t" + arg[i];
    }
    for (int i = 0; i < xuesheng.length - 1; i++) {
    for (int j = 0; j < xuesheng.length - 1; j++) {
    if (s[j] < s[j + 1]) {
    int a = s[j];
    String b = all[j];
    s[j] = s[j + 1];
    all[j] = all[j + 1];
    s[j + 1] = a;
    all[j + 1] = b;
    }
    }
    }
    System.out.print("学生" + "\t");
    for (int i = 0; i < course.length; i++) {
    System.out.print(course[i] + "\t");
    }
    System.out.println("总分\t平均分\t排行榜");
    for (int i = 0; i < xuesheng.length; i++) {
    System.out.println(all[i] + "\t第" + (i + 1) + "名");
    }
      
    }
      

  2.   

    你的成绩数组是int类型,然后输入了“李四”不是数字,输入方法nextInt()报的错