代码已经编译通过
import java.util.*;
public class MainClass_StudentInfor{
public static void main(String args[]){
boolean e=true;
Student stu=new Student();
Scanner sc=new Scanner(System.in);
while(e){
System.out.println("\t\t\t\t\t*********欢迎进入学生信息系统*********\t\t\t\t\t");
System.out.println("\t\t\t\t\t********** 1:录入学生的信息********\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********2:输出信息**************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********3:求总分****************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********4求均分*****************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********5:成绩排序**************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********6:检索成绩**************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********7:求最大值和最小值**************\t\t\t\t\t");
System.out.println("\t\t\t\t\t***********8:结束程序 ***************\t\t\t\t\t");
try{
byte b=sc.nextByte();
switch(b){
case 1:
stu.inputInfo();break;
case 3:
stu.getSum();break;
case 4:
stu.getAver();break;
case 2:
stu.printInfo();break;
case 5:
stu.sort();break;
case 6:
stu.index();break;
case 7:
stu.indexBL();break;
case 8:
e=false;
}
}
catch(NullPointerException f){
f.printStackTrace();
System.out.println("请正确操作");
}
}
}
}
enum Sex{
男,女
}
class Student{
int number;
Sex a;
String name;
float sum=0;
float average;
float score[];
String subject[]={"高数","英语","C语言"};
void inputInfo(){//录入学生基本信息
Scanner sc=new Scanner(System.in);
System.out.println("请输入学号 :");
number=sc.nextInt();
System.out.println("请输入姓名 :");
name=sc.next();
System.out.println(" 请输入性别 1:男,2:女");
int x=sc.nextInt();
if(x==1)
{
a=Sex.男;
}
else
{
a=Sex.女;
}
System.out.println("请输入高数,英语,c语言的成绩:");
score=new float[3];
for(int i=0;i<=2;i++)
{
score[i]=sc.nextFloat();
System.out.println(subject[i]+":"+score[i]);
}
}
void printInfo(){//输出学生基本信息
System.out.println("学号:"+number);
System.out.println("姓名:"+name);
System.out.println("性别:"+a);
for(int i=0;i<3;i++){
System.out.println(subject[i]+":"+score[i]);
}
}
void getSum(){
for(int i=0;i<=2;i++)
{
sum=sum+score[i];
}
System.out.println(" 学生的总分:"+sum);
}
void getAver(){
for(int i=0;i<=2;i++){
sum=sum+score[i];
}
average=sum/3;
System.out.println(" 学生的平均成绩:"+average);
}
void sort(){//排序
Arrays.sort(score);
System.out.println("学生的成绩排序为:"+Arrays.toString(score));
}
void index(){//查询成绩
boolean n=true;
while(n){
Scanner sc=new Scanner(System.in);
System.out.println("请输入,1检索开始,2检索结束");
int m=sc.nextInt();
switch(m){
case 1:
System.out.println("请输入您要查找那门课的成绩0:高数;1:英语:2:C语言");
Scanner sc1=new Scanner(System.in);
int c=sc1.nextInt();
System.out.println(subject[c]+score[c]);
System.out.println("您是否还要查找其他科目的成绩");
break;
case 2:
n=false;
}
}
}
void indexBL(){
float biggest=0;
float lowest=100;
for(int i=0;i<3;i++){
if(biggest<=score[i]){
biggest=score[i];
}
if(lowest>=score[i]){
lowest=score[i];
}
}
System.out.println("该生的最高成绩是"+biggest);
System.out.println("该生的最低成绩是"+lowest);
}
}
现在编写不了了,电脑坏掉了