//20183761 司宇明
ScoreInformation.java
import java.lang.Object;
class ScoreInformation {
private String stunumber;
private String name;
private double mathematicsscore;
private double englishscore;
private double networkscore;
private double databasescore;
private double softwarescore;
public ScoreInformation() {
this.stunumber=stunumber;
this.name=name;
this.mathematicsscore=mathematicsscore;
this.englishscore=englishscore;
this.networkscore=networkscore;
this.databasescore=databasescore;
this.softwarescore=softwarescore;
}
//stunumber 的 getter setter
public void setStunumber(String stunumber) {
this.stunumber=stunumber;
}
public String getStunumber() {
return stunumber;
}
//name 的 getter setter
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
//mathematicsscore 的 getter setter
public void setMathematicsscore(double mathematicsscore) {
this.mathematicsscore=mathematicsscore;
}
public double getMathematicsscore() {
return mathematicsscore;
}
//englishscore 的 getter setter
public void setEnglishscore(double englishscore) {
this.englishscore=englishscore;
}
public double getEnglishscore() {
return englishscore;
}
//networkscore 的 getter setter
public void setNetworkscore(double networkscore) {
this.networkscore=networkscore;
}
public double getNetworkscore() {
return networkscore;
}
//databasescore 的 getter setter
public void setDatabasescore(double databasescore) {
this.databasescore=databasescore;
}
public double getDatabasescore() {
return databasescore;
}
//softscore 的 getter setter
public void setSoftwarescore(double softwarescore) {
this.softwarescore=softwarescore;
}
public double getSoftwarescore() {
return softwarescore;
}
}
ScoreManagement.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class ScoreManagement {
ScoreInformation a[]=new ScoreInformation[10];
int sum = 0;
void setManager(int n) throws IOException //输入学生信息
{
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
String str = null;
for(int i=0;i<n;i++)
{
a[i] = new ScoreInformation(); //定义对象,开辟空间
String stunumber=reader.readLine();
a[i].setStunumber(stunumber);
String name=reader.readLine();
a[i].setName(name);
double mathematicsscore = Double.parseDouble(str);
a[i].setMathematicsscore(mathematicsscore);
double englishscore = Double.parseDouble(str);
a[i].setEnglishscore(englishscore);
double networkscore = Double.parseDouble(str);
a[i].setNetworkscore(networkscore);
double databasescore = Double.parseDouble(str);
a[i].setDatabasescore(databasescore);
double softwarescore = Double.parseDouble(str);
a[i].setSoftwarescore(softwarescore);
}
this.sum = n;
}
void addStudent(String stunumber,String name,int age,double mathematicsscore,double englishscore,double networkscore,
double databasescore,double softwarescore) throws IOException
{
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩录入 ");
System.out.println("***********************************************************");
System.out.println("请输入学生学号:");
//新添加一个学生的信息
String str="";
int t=0;
for(int i=0;i<sum;i++)
if(a[i].getStunumber().equals(stunumber))
{
t=1;
}
if(t==0)
{
a[sum]=new ScoreInformation();
a[sum].setStunumber(stunumber);
a[sum].setName(name);
System.out.println("学生学号:"+stunumber);
System.out.println("学生姓名:"+name);
System.out.println("请输入高等数学成绩:");
a[sum].setMathematicsscore(mathematicsscore);
System.out.println("高等数学成绩:"+mathematicsscore);
System.out.println("请输入大学英语成绩:");
a[sum].setEnglishscore(englishscore);
System.out.println("大学英语成绩:"+englishscore);
System.out.println("请输入计算机网络成绩:");
a[sum].setNetworkscore(networkscore);
System.out.println("计算机网络成绩:"+networkscore);
System.out.println("请输入数据库成绩:");
a[sum].setDatabasescore(databasescore);
System.out.println("数据库成绩:"+databasescore);
sum+=1;
System.out.println("添加成功!");
System.out.println("该学生成绩已录入完毕,是否提交(Y/N)");
char ch;
String str1;
Scanner In=new Scanner(System.in);
str1=In.next();
ch=str1.charAt(0);
if(ch=='Y'||ch=='y')
{
this.addStudent(str1, str1, t, softwarescore, softwarescore, softwarescore, softwarescore, softwarescore);
}
if(ch=='N'||ch=='n')
{
this.menu();
}
}
else
System.out.println("学号已存在");
System.out.println("***********************************************************");
}
void updateStudent(String stunumber,String name,int age,double mathematicsscore,double englishscore,double networkscore,
double databasescore,double softwarescore)
{
//根据学号修改学生信息
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩修改界面 ");
System.out.println("***********************************************************");
System.out.println("请输入学生学号: ");
int i=0;
if(a[i].getStunumber().equals(stunumber))
{
System.out.println("学生学号: ");
System.out.println("学生姓名: ");
System.out.println("1、高等数学成绩: "+a[i].getMathematicsscore());
System.out.println("2、大学英语成绩: "+a[i].getEnglishscore());
System.out.println("3、计算机网络成绩: "+a[i].getNetworkscore());
System.out.println("4、数据库成绩: "+a[i].getDatabasescore());
System.out.println("5、软件工程成绩: "+a[i].getSoftwarescore());
}
System.out.println("请输入修改后成绩 ");
b=in.nextInt();
switch(b)
{
case 1:a[i].setMathematicsscore(mathematicsscore);break;
case 2:a[i].setEnglishscore(englishscore);break;
case 3:a[i].setNetworkscore(networkscore);break;
case 4:a[i].setDatabasescore(databasescore);break;
case 5:a[i].setSoftwarescore(softwarescore);break;
}
System.out.println("该学生成绩已修改完毕,是否提交(Y/N)");
char ch2;
String str2;
Scanner In=new Scanner(System.in);
str2=In.next();
ch2=str2.charAt(0);
if(ch2=='Y'||ch2=='y')
{
this.addStudent();
}
if(ch2=='N'||ch2=='n')
{
this.menu();
}
System.out.println("***********************************************************");
}
public void menu() {
int a;
Scanner in = new Scanner(System.in);
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学软件工程系 ");
System.out.println(" 学生学籍管理系统 2019 版 ");
System.out.println("***********************************************************");
System.out.println(" 1、 学生考试成绩录入 ");
System.out.println(" 2、 学生考试成绩修改 ");
System.out.println(" 3、 计算学生成绩绩点 ");
System.out.println(" 4、 退出学籍管理系统 ");
System.out.println("***********************************************************");
System.out.println(" ");
System.out.println("请选择(1~4):");
a=in.nextInt();
while(a<1||a>4)
{
System.out.print("输入超出范围,请重新输入:");
a=in.nextInt();
}
switch(a)
{
case 1:this.addStudent();break;
case 2:this.updateStudent();break;
case 3:this.cal();break;
case 0:System.exit(0);break;
}
}
}
Main.java
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
ScoreInformation stu=new ScoreInformation();
for(int i=0;i<2;i++)
{
a[i]=new ScoreInformation();
}
stu.menu();
}
}