码迷,mamicode.com
首页 > 编程语言 > 详细

Java考试

时间:2019-09-12 21:19:29      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:生成   show   vat   实现   xxx   while   错误   turn   format   

  本周一进行了java编程考试,下面是具体代码:

 

 

首先是ScoreInformation类来存储学生信息。

    

public class ScoreInformation {
private String stunumber;
private String name;
private double mathematicsscore;
private double englishiscore;
private double networkscore;
private double databasescore;
private double softwarescore;

public ScoreInformation(String name,String stunumber,double mathematicsscore,double englishiscore,double networkscore,double databasescore,double softwarescore ){
this.name= name;
this.stunumber= stunumber;
this.mathematicsscore = mathematicsscore;
this.networkscore = networkscore;
this.databasescore = databasescore;
this.softwarescore = softwarescore;
this.englishiscore = englishiscore;
}

public String getstunumber(){
return stunumber;
}
public void setstunumber(String stunumber) {
this.stunumber = stunumber;
}
public String getname(){
return name;
}
public void setname(String name) {
this.name = name;
}
public double getmathematicsscore(){
return mathematicsscore;
}
public void setmathematicsscore(double mathematicsscore) {
this.mathematicsscore = mathematicsscore;
}
public double getnetworkscore(){
return networkscore;
}
public void setnetworkscore(double networkscore) {
this.networkscore = networkscore;
}
public double getdatabasescore(){
return databasescore;
}
public void setdatabasescore(double databasescore) {
this.databasescore = databasescore;
}
public double getsoftwarescore(){
return softwarescore;
}
public void setsoftwarescore(double softwarescore) {
this.softwarescore = softwarescore;
}
public double getenglishiscore(){
return englishiscore;
}
public void setenglishiscore(double englishiscore) {
this.englishiscore = englishiscore;
}
}

 

 

 然后是ScoreManagement类来实现功能

 

//信1805-1薛秋香20183535
import java.util.*;
public class A{

public static void main(String[] args) {
mingdan() ;
int c1=0;
c1=menu();
while(true){
switch(c1) {
case 1:lr();break;
case 2:gai();break;
case 3:jidian();break;
case 4:exit();break;
default :System.out.println("错误");
break;
}
c1=menu();


}

}

static int t=0;
static String B;
static int sum=5;
static double []r=new double[6];
static double jl=0.0;
static Scanner sc=new Scanner(System.in);
static ScoreInformation[] a = new ScoreInformation[1000];


public static int menu();{
System.out.println("***********************************************************\r\n" +
"石家庄铁道大学软件工程系\r\n" +
"学生学籍管理系统 2019 版\r\n" +
"***********************************************************\r\n" +
"1、 学生考试成绩录入\r\n" +
"2、 学生考试成绩修改\r\n" +
"3、 计算学生成绩绩点\r\n" +
"4、退出学籍管理系统\r\n" +
"**********************************************************");
int ch;
System.out.println("请选择:");
ch = sc.nextInt();
}

public static String input() {

String stunum1;
System.out.println("***********************************************************\r\n" +
"石家庄铁道大学软件工程系学生学籍管理系统 2019 版\r\n" +
"学生考试成绩录入\r\n" +
"***********************************************************\r\n" +
"请输入学生学号:XXXXXXXX\r\n" +
"**********************************************************");
System.out.println( "输入学生学号:");
stunum1=sc.next();
return stunum1;
}

public static void one() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入高等数学成绩:"+"\n"+
"****************************************************************");
b=sc.nextDouble();
a[t].setmathematicsscore(b);
two();
}

public static void two() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 请输入大学英语成绩:"+"\n"+
"****************************************************************");
b=sc.nextDouble();
a[t].setenglishiscore(b);
three();
}

public static void three() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 大学英语成绩:"+a[t].getenglishiscore()+"\n"+
" 请输入计算机网络成绩: "+"\n"+
"****************************************************************");
b=sc.nextDouble();
a[t].setnetworkscore(b);
four();
}

public static void four() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 大学英语成绩:"+a[t].getenglishiscore()+"\n"+
" 计算机网络成绩:"+a[t].getnetworkscore()+"\n"+
" 请输入数据库成绩:"+"\n"+
"****************************************************************");
b=sc.nextDouble();
a[t].setdatabasescore(b);
five();
}

public static void five() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 大学英语成绩:"+a[t].getenglishiscore()+"\n"+
" 计算机网络成绩:"+a[t].getnetworkscore()+"\n"+
" 数据库成绩:"+a[t].getdatabasescore()+"\n"+
" 请输入软件工程成绩:"+"\n"+
"****************************************************************");
b=sc.nextDouble();
a[t].setsoftwarescore(b);
six();
}

public static void six() {
String b;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getStunumber()+"\n"+
" 学生姓名:"+a[t].getName()+"\n"+
" 高等数学成绩:"+a[t].getMathematicsscore()+"\n"+
" 大学英语成绩:"+a[t].getEnglishiscore()+"\n"+
" 计算机网络成绩:"+a[t].getNetworkscore()+"\n"+
" 数据库成绩:"+a[t].getDatabasescore()+"\n"+
" 软件工程成绩:"+a[t].getSoftwarescore()+"\n"+
"*************************************************************** \n" +
"该学生的成绩已录入,是否提交(Y/N)");
b=sc.next();
if(b.compareTo("N")==0) {
a[t]=new ScoreInformation(a[t].getstunumber(),a[t].getname(),0,0,0,0,0);
lr();
}
else {
return;
}
}


public static void lr() {
int f=0;
String stunum2=input();
for(int i=0;i<5;i++) {
if(a[i].getstunumber().compareTo(stunum2)==0) {
t=i;
f=1;
one();
break;
}

}
if(f==0) {
System.out.println("错误!");
stunum2=input();
lr();
return;
}


}


public static void mingdan() {
a[0]=new ScoreInformation("20183535","薛秋香",0,0,0,0,0);
a[1]=new ScoreInformation("20183536","一",0,0,0,0,0);
a[2]=new ScoreInformation("20183537","二",0,0,0,0,0);
a[3]=new ScoreInformation("20183538","三",0,0,0,0,0);
a[4]=new ScoreInformation("20183539","四",0,0,0,0,0);

}


public static String xiugai() {
String stunum1;
System.out.println("***********************************************************\r\n" +
"石家庄铁道大学软件工程系学生学籍管理系统 2019 版\r\n" +
"学生考试成绩修改界面\r\n" +
"***********************************************************\r\n" +
"请输入学生学号:XXXXXXXX\r\n" +
"**********************************************************");
System.out.println( "输入学生学号:");
stunum1=sc.next();
return stunum1;
}

public static void gai() {
int f=0;
String stunumber2=xiugai();
for(int i=0;i<5;i++) {
if(a[i].getstunumber().compareTo(stunumber2)==0) {
t=i;
f=1;
int z=ten();
while(true) {
switch(z) {
case 1:
eleven();
if(B.equals("N")) {
a[t].setmathematicsscore(jl);
gai();
}
break;
case 2:
twelve();
if(B.equals("N")) {
a[t].setenglishiscore(jl);;
gai();
}
break;
case 3:
threeteen();
if(B.equals("N")) {
a[t].setnetworkscore(jl);;
gai();
}
break;
case 4:
fourteen();
if(B.equals("N")) {
a[t].setdatabasescore(jl);;
gai();
}
break;
case 5:
fifteen();
if(B.equals("N")) {
a[t].setsoftwarescore(jl);;
gai();
}

break;

}
break;
}

}

}
if(f==0) {
System.out.println("错误!");
stunumber2=input();
lr();
return;
}
}

public static int ten() {
int f=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 1,高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 2,大学英语成绩:"+a[t].getenglishiscore()+"\n"+
" 3,计算机网络成绩:"+a[t].getnetworkscore()+"\n"+
" 4, 数据库成绩:"+a[t].getdatabasescore()+"\n"+
" 5,软件工程成绩:"+a[t].getsoftwarescore()+"\n"+
"**************************************************************** \\n");
f=sc.nextInt();
return f;
}

public static void eleven() {
double b=0;

System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入修改后的高等数学成绩:");
b=sc.nextDouble();
jl=a[t].getmathematicsscore();
a[t].setmathematicsscore(b);
sixteen();
}
public static void twelve() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入修改后的英语成绩:");
b=sc.nextDouble();
jl=a[t].getenglishiscore();
a[t].setmathematicsscore(b);
sixteen();
}

public static void threeteen() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入修改后的计算机网络成绩:");
b=sc.nextDouble();
jl=a[t].getnetworkscore();
a[t].setnetworkscore(b);
sixteen();
}
public static void fourteen() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入修改后的数据库成绩:");
b=sc.nextDouble();
jl=a[t].getdatabasescore();
a[t].setdatabasescore(b);
sixteen();
}
public static void fifteen() {
double b=0;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 请输入修改后的软件工程成绩:");
b=sc.nextDouble();
jl=a[t].getsoftwarescore();
a[t].setsoftwarescore(b);
sixteen();
}
public static void sixteen() {
String b;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩录入 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 高等数学成绩:"+a[t].getmathematicsscore()+"\n"+
" 大学英语成绩:"+a[t].getenglishiscore()+"\n"+
" 计算机网络成绩:"+a[t].getnetworkscore()+"\n"+
" 数据库成绩:"+a[t].getdatabasescore()+"\n"+
" 软件工程成绩:"+a[t].getsoftwarescore()+"\n"+
"该学生的成绩已修改完毕,是否提交(Y/N)");
b=sc.next();
B=b;
if(b.compareTo("N")==0) {
a[t]=new ScoreInformation(a[t].getstunumber(),a[t].getname(),0,0,0,0,0);
gai();
}
else {
return;
}

}

public static String jd() {
String str;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩基点计算 \n" +
"**************************************************************** \n" +
" 请输入学生学号(学号为八位):\n"+
"****************************************************************");
str=sc.next();
return str;

}

public static void show() {
String b;
System.out.println("*************************************************************** \n" +
" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 \n" +
" 学生考试成绩基点计算 \n" +
"**************************************************************** \n" +
" 学生学号:"+a[t].getstunumber()+"\n"+
" 学生姓名:"+a[t].getname()+"\n"+
" 1,高等数学成绩基点:"+r[0]+"\n"+
" 2,大学英语成绩基点:"+r[1]+"\n"+
" 3,计算机网络成绩基点:"+r[2]+"\n"+
" 4, 数据库成绩基点:"+r[3]+"\n"+
" 5, 软件工程成绩基点:"+r[4]);
if(pingjun()>=2)
System.out.println(" 你的学分绩点已达到毕业要求!");
else
System.out.println(" 你的学分绩点未达到毕业要求!");
System.out.println(" 是否返回(Y/N)");
b=sc.next();

if(b.equals("Y"))
return;
else
{}
}
public static void jidian() {
String s=jd();
int f=0;
for(int i=0;i<5;i++) {
if(s.equals(a[i].getstunumber())) {
t=i;
f=1;
r[0]=jidianJisuan(a[i].getmathematicsscore());
r[1]=jidianJisuan(a[i].getenglishiscore());
r[2]=jidianJisuan(a[i].getnetworkscore());
r[3]=jidianJisuan(a[i].getdatabasescore());
r[4]=jidianJisuan(a[i].getsoftwarescore());
show();
break;
}
}
if(f==0) {
System.out.println("错误!");
jidian();
}
}

public static double pingjun() {
double p1=0,p2=0,p=0;
p1=r[0]*4+r[1]*3+r[2]*4+r[3]*3+r[4]*2;
p2=16;
p=p1/p2;

return p;
}

public static double jidianJisuan(double j) {
double k=0.0;
if(j>=90) {
k=4.0;
return k;
}
if(j<60) {
k=0.0;
return k;
}
if(k>=72) {
if(k<=74.9)
k=2.3;
if(k<=77.9)
k=2.7;
if(k<=81.9)
k=3.0;
if(k<=84.9)
k=3.3;
if(k<=89.9)
k=3.7;
}
else {
if(k>=68)
k=2.0;
if(k>=66)
k=1.7;
if(k>=64)
k=1.5;
if(k>=60)
k=1.0;
}

return k;
}
public static void exit() {
System.out.println("*************************************************************** \n" +
"谢谢使用石家庄铁道大学软件工程系学生学籍管理系统 2019 版\n"+
" 制作人:薛秋香\n"+
"****************************************************************");
}


}

 

 

设计思路


首先完成各个功能的单独部分,然后拼接在一起,最后用主函数完成功能的选择。

 

Java考试

标签:生成   show   vat   实现   xxx   while   错误   turn   format   

原文地址:https://www.cnblogs.com/xueqiuxiang/p/11514601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!