简单小型的学生管理系统

//欢迎吐槽.....

package 练习;

import java.util.Scanner;
public class 学生管理系统 
{
public static void main(String[] args)
{
System.out.println("请输入学生的人数:");
Scanner in=new Scanner(System.in);
int number=in.nextInt();
System.out.println("请输入课程的数目");
int number2=in.nextInt();
int i,j;
float[] avg=new float[number+1];
int[] sum=new int[number+1];
int[][] chengji=new int[number+1][number2+1];
String[] name=new String[number+1];
String[] course=new String[number2+1];
int[]  rank=new int[number+1];

Scanner ing=new Scanner(System.in,"GBK");

for(i=1;i<=number2;i++)
{
System.out.println("请定义第"+i+"门课程是什么?");
course[i]=ing.nextLine();
//System.out.println();
}
//System.out.println();

for(i=1;i<=number;i++)
{
System.out.println("请输入第"+i+"个同学的名字");
name[i]=ing.nextLine();
sum[i]=0;
//System.out.println();
for(j=1;j<=number2;j++)
{
System.out.println("请输入"+name[i]+"的第"+course[j]+"门的成绩");
chengji[i][j]=in.nextInt();
System.out.println();
sum[i]+=chengji[i][j];
}

avg[i]=(float)sum[i]/number2;
}
for(i=1;i<=number;i++)
{
rank[i]=1;
for(j=1;j<=number;j++)
{

if(sum[i]<sum[j])

rank[i]++;

}
}
System.out.print("学生\t\t");
for(i=1;i<=number2;i++)
{
System.out.print(course[i]+"\t\t");

}
System.out.println("总分\t\t平均分\t\t排行榜");
for(i=1;i<=number;i++)
{
System.out.print(name[i]+"\t\t");
for(j=1;j<=number2;j++)
{
System.out.print(chengji[i][j]+"\t\t");
}
System.out.println(sum[i]+"\t\t"+avg[i]+"\t\t"+"第"+rank[i]+"名");

}
}


}

运行结果示意图:简单小型的学生管理系统_第1张图片


你可能感兴趣的:(小型学生管理系统)