📄 studentsystem.java
字号:
int m = 0;
for (int i =0;i<count;i++)
{
if(sno.equals(all_students[i].sno))
{
m = i;
break;
}
}
for(int j=m;j<count-1;j++)
{
all_students[j] = all_students[j+1];
}
count--;
}
void printAllStudents() //打印所有的学生信息
{
System.out.println("——————————");
System.out.println("学号 姓名 性别 成绩");
for(int i=0;i<count;i++)
{
System.out.println(all_students[i].sno+" "+all_students[i].sname+" "+all_students[i].sex+" "+all_students[i].score);
}
System.out.println("——————————");
if(count == 0)
{
System.out.println();
System.out.println("***没有学生信息!***");
System.out.println();
}
else
{
System.out.println("——总计:"+StudentArrangement.count+" 条学生信息!");
System.out.println();
}
}
void show1()
{
System.out.println("*************************************");
System.out.println("*** 欢迎进入学生成绩管理系统 ***");
System.out.println("*************************************");
System.out.println("*** 1.增加学生信息! ***");
System.out.println("*** 2.查询学生信息! ***");
System.out.println("*** 3.修改学生信息! ***");
System.out.println("*** 4.删除学生信息! ***");
System.out.println("*** 5.排列学生信息! ***");
System.out.println("*** 6.打印学生信息! ***");
System.out.println("*** 7.全部删除学生信息! ***");
System.out.println("*** 8.作者信息! ***");
System.out.println("*** 0.退出判断! ***");
System.out.println("*************************************");
System.out.println("*************************************");
System.out.println("请选择判断: (0……8)");
}
void show2()
{
System.out.println("************************");
System.out.println("*** 1.按学号查询: ***");
System.out.println("*** 2.按姓名查询: ***");
System.out.println("*** 3.按成绩查询: ***");
System.out.println("*** 0.退出查询操作!***");
System.out.println("************************");
System.out.println("请选择查询方式: (0……3)");
}
void show3()
{
System.out.println("************************");
System.out.println("*** 1.按学号排序: ***");
System.out.println("*** 2.按成绩排序: ***");
System.out.println("*** 0.退出排序操作!***");
System.out.println("************************");
System.out.println("请选择排序方式: (0……2)");
}
}
public class StudentSystem
{
public static void main(String args[])
{
Student[] new_student= new Student[50];
new_student[0]=new Student("200901","张三","F","60");
new_student[1]=new Student("200904","李四","M","83");
new_student[2]=new Student("200902","王五","F","70");
new_student[3]=new Student("200909","张三","M","97");
new_student[4]=new Student("200906","小明","M","70");
new_student[5]=new Student("200908","王康","M","65");
new_student[6]=new Student("200910","刘刚","M","50");
new_student[7]=new Student("200905","张梅","F","100");
new_student[8]=new Student("200907","郭华","M","76");
new_student[9]=new Student("200903","赵六","M","83");
StudentArrangement m = new StudentArrangement();
m.all_students = new_student;
StudentArrangement.count = 10;
m.show1();
Scanner sc1 = new Scanner(System.in);
int temp1 = sc1.nextInt();
while (temp1 != 0)
{
switch(temp1)
{
case 1 : // 添加学生信息
System.out.println("***添加学生信息:***");
System.out.println("——请输入学号:(六位数字并且前四位为2009)");
String args1 = sc1.next();
//判断输入的学号是否有误(合法、唯一),有误请重新输入
while(m.addStudentJudgeSno(args1) == 0 || m.addStudentJudgeSnoUnique(args1) == 0)
{
System.out.println("您输入的学号不对,请重新输入:");
args1 = sc1.next();
if(m.addStudentJudgeSno(args1) == 1 && m.addStudentJudgeSnoUnique(args1) == 1)
{
break;
}
}
System.out.println("——请输入姓名:");
String args2 = sc1.next();
System.out.println("——请输入性别:(F/M)");
String args3 = sc1.next();
//判断输入的性别是否合法,不合法请重新输入
while(m.addStudentJudgeSex(args3) != 1)
{
System.out.println("您输入的性别不合法,请重新输入:");
args3 = sc1.next();
if(m.addStudentJudgeSex(args3) == 1)
{
break;
}
}
System.out.println("——请输入成绩:(10……100)");
String args4 = sc1.next();
//判断输入的成绩是否合法,不合法请重新输入
while(m.addStudentJudgeScore(args4) != 1)
{
System.out.println("您输入的成绩不合法,请重新输入:");
args4 = sc1.next();
if(m.addStudentJudgeScore(args4) == 1)
{
break;
}
}
Student t = new Student(args1,args2,args3,args4);
m.addStudent(t);
System.out.println("——添加成功!");
System.out.println();
break;
case 2 : // 查询学生信息(按不同方式查询)
m.show2();
Scanner sc2 = new Scanner(System.in);
int temp2 = sc2.nextInt();
while (temp2 != 0)
{
switch(temp2)
{
case 1 :
System.out.println("——请输入学号:");
String args5 = sc2.next();
m.searchStudentSno(args5);
System.out.println();
break;
case 2 :
System.out.println("——请输入姓名:");
String args6 = sc2.next();
m.searchStudentSname(args6);
System.out.println();
break;
case 3 :
System.out.println("——请输入成绩:");
String args7 = sc2.next();
m.searchStudentScore(args7);
System.out.println();
break;
}
m.show2();
temp2 = sc2.nextInt();
}
break;
case 3 : // 修改学生信息
System.out.println("——请输入要修改的学生学号:");
String args8 = sc1.next();
m.searchStudentSno(args8);
if(m.number == 0)
{
System.out.println("请选择其他操作:");
break;
}
System.out.println("修改该学生的成绩为:");
String args9 = sc1.next();
//判断输入的成绩是否合法,不合法请重新输入
while(m.addStudentJudgeScore(args9) != 1)
{
System.out.println("您输入的成绩不合法,请重新输入:");
args9 = sc1.next();
if(m.addStudentJudgeScore(args9) == 1)
{
break;
}
}
m.modifyStudentSno(args8,args9);
System.out.println("——修改成功");
System.out.println();
break;
case 4 : // 删除学生信息
System.out.println("请输入要删除的学生学号:");
String args10 = sc1.next();
m.searchStudentSno(args10);
if(m.number == 0)
{
System.out.println("请选择其他操作:");
break;
}
System.out.println("确定要删除学号为: "+args10+" 的学生信息吗?");
System.out.println("***是,请按1***"+" "+"***退出删除操作,请按0***");
Scanner sc3 = new Scanner(System.in);
int temp3 = sc3.nextInt();
while (temp3 != 0)
{
switch(temp3)
{
case 1 :
m.deleteStudent(args10);
System.out.println();
System.out.println("——删除成功!");
System.out.println();
System.out.println("——请按0退出删除操作");
break;
}
temp3 = sc3.nextInt();
}
break;
case 5 : // 排列学生信息
m.show3();
Scanner sc4 = new Scanner(System.in);
int temp4 = sc4.nextInt();
while (temp4 != 0)
{
switch(temp4)
{
case 1 :
m.arrangeALLStudentSno();
System.out.println("排列后所有的学生信息如下:");
m.printAllStudents();
break;
case 2 :
m.arrangeALLStudentScore();
System.out.println("排列后所有的学生信息如下:");
m.printAllStudents();
break;
}
m.show3();
temp4 = sc4.nextInt();
}
break;
case 6 : // 打印全部学生信息
System.out.println("所有的学生信息打印如下:");
m.printAllStudents();
break;
case 7 : // 删除全部学生信息
System.out.println("确定要删除所有的学生信息吗?");
System.out.println("***是,请按1***"+" "+"***退出删除操作,请按0***");
Scanner sc5 = new Scanner(System.in);
int temp5 = sc5.nextInt();
while (temp5 != 0)
{
switch(temp5)
{
case 1 :
StudentArrangement.count = 0;
System.out.println();
System.out.println("——全部学生信息已删除!");
System.out.println();
System.out.println("——请按0退出删除操作");
}
temp5 = sc5.nextInt();
}
break;
case 8 : // 打印作者信息
System.out.println("Version: "+"1.0"+" "+"Copyright: "+"刘少波");
break;
}
m.show1();
temp1 = sc1.nextInt();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -