Java开学测试
Posted kdmvp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java开学测试相关的知识,希望对你有一定的参考价值。
package com.开学测试;
import java.util.Scanner;
/* 信1805-3班 */
/* 方岩 */
class ScoreInformation
private String stunumber;
private String name;
private double mathematicsscore;
private double englishiscore;
private double networkscore;
private double databasescore;
private double softwarescore;
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 getEnglishiscore()
return englishiscore;
public void setEnglishiscore(double englishiscore)
this.englishiscore = englishiscore;
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 class ScoreManagement
Scanner in=new Scanner(System.in);
public void display1()
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("*******************************");
public int find(String t)
int i=0,k=0;
for(i=0;i<5;i++)
if(s[i].getStunumber().compareTo(t)==0)
k=1;
break;
if(k==0)
return -1;
else
return i;
public void display2()
System.out.println("*******************************");
System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩录入 ");
System.out.println("*******************************");
public void display3()
System.out.println("*******************************");
System.out.println("谢谢使用石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 制作人:方岩 ");
System.out.println("*******************************");
public void display4(int k)
System.out.println("*******************************");
System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩录入界面 ");
System.out.println("*******************************");
System.out.println(" 学生学号:"+s[k].getStunumber());
System.out.println(" 学生姓名:"+s[k].getName());
static int con=0;
static int w2=0;
public void display5(int p)
double x;
System.out.println("*******************************");
System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩录入界面 ");
System.out.println("*******************************");
System.out.println(" 学生学号:"+s[p].getStunumber());
System.out.println(" 学生姓名:"+s[p].getName());
con++;
if(s[p].getMathematicsscore()!=0)
System.out.println(" 1.高等数学成绩为:"+s[p].getMathematicsscore());
if(s[p].getEnglishiscore()!=0)
System.out.println(" 2.大学英语成绩为:"+s[p].getEnglishiscore());
if(s[p].getNetworkscore()!=0)
System.out.println(" 3.计算机网络成绩为:"+s[p].getNetworkscore());
if(s[p].getDatabasescore()!=0)
System.out.println(" 4.数据库成绩为:"+s[p].getDatabasescore());
if(con==5||w2==1)
System.out.println(" 5.软件工程成绩为:"+s[p].getSoftwarescore());
public void display6()
System.out.println("*******************************");
System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩修改界面 ");
System.out.println("*******************************");
public void display7()
System.out.println("*******************************");
System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
System.out.println(" 学生考试成绩绩点计算界面 ");
System.out.println("*******************************");
static ScoreInformation []s=new ScoreInformation[10];
public static void main(String[] args)
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ScoreManagement stu=new ScoreManagement();
boolean flag=true,flag2=true,flag3=true,flag4=true,flag5=true,flag6=true;
String xuehao;
int i,number;
for(i=0;i<10;i++)
s[i]=new ScoreInformation();
s[0].setStunumber("20183516");
s[0].setName("A");
s[1].setStunumber("20183517");
s[1].setName("B");
s[2].setStunumber("20183518");
s[2].setName("C");
s[3].setStunumber("20183519");
s[3].setName("D");
s[4].setStunumber("20183520");
s[4].setName("E");
for(i=0;i<5;i++)
s[i].setDatabasescore(0);
s[i].setEnglishiscore(0);
s[i].setMathematicsscore(0);
s[i].setNetworkscore(0);
s[i].setSoftwarescore(0);
while(flag)
stu.display1();
System.out.println("请选择要执行的功能序号");
number=in.nextInt();
if(number<1||number>4)
System.out.println("该选项不存在");
else
switch(number)
case 1:
while(flag2==true)
stu.display2();
in.nextLine();
System.out.println("请输入学生学号:");
xuehao=in.nextLine();
System.out.println("*******************************");
if(stu.find(xuehao)==-1)
flag2=true;
System.out.println("该不存在");
else
double m;
String c;
flag2=false;
int b=stu.find(xuehao);
stu.display4(b);
System.out.println("请输入高等数学成绩:");
m=in.nextDouble();
s[b].setMathematicsscore(m);
stu.display5(b);
System.out.println("请输入大学英语成绩:");
m=in.nextDouble();
s[b].setEnglishiscore(m);
stu.display5(b);
System.out.println("请输入计算机网络成绩:");
m=in.nextDouble();
s[b].setNetworkscore(m);
stu.display5(b);
System.out.println("请输入数据库成绩:");
m=in.nextDouble();
s[b].setDatabasescore(m);
stu.display5(b);
System.out.println("请输入软件工程成绩:");
m=in.nextDouble();
s[b].setSoftwarescore(m);
stu.display5(b);
System.out.println("该学生成绩已录入完毕,是否提交(Y/N) ");
c=in.next();
if(c.compareTo("N")==0)
flag2=true;
s[b].setDatabasescore(0);
s[b].setEnglishiscore(0);
s[b].setMathematicsscore(0);
s[b].setNetworkscore(0);
s[b].setSoftwarescore(0);
break;
case 2:
String q;
while(flag3==true)
stu.display6();
in.nextLine();
System.out.println("请输入学号:");
q=in.nextLine();
System.out.println("*******************************");
if(stu.find(q)==-1)
flag3=true;
System.out.println("该不存在");
else
int r;
int k=stu.find(q);
double j;
w2=1;
flag3=false;
stu.display5(k);
System.out.println("请选择要修改的成绩序号:");
r=in.nextInt();
if(r==1)
String m;
double old;
stu.display4(k);
old=s[k].getMathematicsscore();
System.out.println("请输入要修改后的高等数学成绩:");
j=in.nextDouble();
s[k].setMathematicsscore(j);
stu.display5(k);
System.out.println("该学生成绩已修改完毕,是否提交(Y/N) ");
m=in.next();
if(m.compareTo("N")==0)
flag3=true;
s[k].setMathematicsscore(old);
else if(r==2)
String m;
double old;
old=s[k].getEnglishiscore();
stu.display4(k);
System.out.println("请输入要修改后的大学英语成绩:");
j=in.nextDouble();
s[k].setEnglishiscore(j);
stu.display5(k);
System.out.println("该学生成绩已修改完毕,是否提交(Y/N) ");
m=in.next();
if(m.compareTo("N")==0)
flag3=true;
s[k].setEnglishiscore(old);
else if(r==3)
String m;
double old;
old=s[k].getNetworkscore();
stu.display4(k);
System.out.println("请输入要修改后的计算机网络成绩:");
j=in.nextDouble();
s[k].setNetworkscore(j);
stu.display5(k);
System.out.println("该学生成绩已修改完毕,是否提交(Y/N) ");
m=in.next();
if(m.compareTo("N")==0)
flag3=true;
s[k].setNetworkscore(old);
else if(r==4)
String m;
double old;
old=s[k].getDatabasescore();
stu.display4(k);
System.out.println("请输入要修改后的数据库成绩:");
j=in.nextDouble();
s[k].setDatabasescore(j);
stu.display5(k);
System.out.println("该学生成绩已修改完毕,是否提交(Y/N) ");
m=in.next();
if(m.compareTo("N")==0)
flag3=true;
s[k].setDatabasescore(old);
else if(r==5)
String m;
double old;
old=s[k].getSoftwarescore();
stu.display4(k);
System.out.println("请输入要修改后的软件工程成绩:");
j=in.nextDouble();
s[k].setSoftwarescore(j);
stu.display5(k);
System.out.println("该学生成绩已修改完毕,是否提交(Y/N) ");
m=in.next();
if(m.compareTo("N")==0)
flag3=true;
s[k].setSoftwarescore(old);
else
System.out.println("请重新输入:");
break;
case 3:
String l;
while(flag4==true)
stu.display7();
in.nextLine();
flag4=false;
System.out.println("请输入学生学号:");
l=in.nextLine();
System.out.println("*******************************");
if(stu.find(l)==-1)
flag4=true;
System.out.println("该不存在");
else
int p=stu.find(l);
double []a=new double[5];
double []g=new double[]4,3,4,3,2;
double v=0;
for(i=0;i<5;i++)
if(i==0)
if(s[p].getMathematicsscore()>=72)
if(s[p].getMathematicsscore()<=74.9)
a[i]=2.3;
else if(s[p].getMathematicsscore()<=77.9)
a[i]=2.7;
else if(s[p].getMathematicsscore()<=81.9)
a[i]=3.0;
else if(s[p].getMathematicsscore()<=84.9)
a[i]=3.3;
else if(s[p].getMathematicsscore()<=89.9)
a[i]=3.7;
else
a[i]=4.0;
else
if(s[p].getMathematicsscore()>=68)
a[i]=2.0;
else if(s[p].getMathematicsscore()>=66)
a[i]=1.7;
else if(s[p].getMathematicsscore()>=64)
a[i]=1.5;
else if(s[p].getMathematicsscore()>=60)
a[i]=1.0;
else
a[i]=0;
if(i==1)
if(s[p].getEnglishiscore()>=72)
if(s[p].getEnglishiscore()<=74.9)
a[i]=2.3;
else if(s[p].getEnglishiscore()<=77.9)
a[i]=2.7;
else if(s[p].getEnglishiscore()<=81.9)
a[i]=3.0;
else if(s[p].getEnglishiscore()<=84.9)
a[i]=3.3;
else if(s[p].getEnglishiscore()<=89.9)
a[i]=3.7;
else
a[i]=4.0;
else
if(s[p].getEnglishiscore()>=68)
a[i]=2.0;
else if(s[p].getEnglishiscore()>=66)
a[i]=1.7;
else if(s[p].getEnglishiscore()>=64)
a[i]=1.5;
else if(s[p].getEnglishiscore()>=60)
a[i]=1.0;
else
a[i]=0;
if(i==2)
if(s[p].getNetworkscore()>=72)
if(s[p].getNetworkscore()<=74.9)
a[i]=2.3;
else if(s[p].getNetworkscore()<=77.9)
a[i]=2.7;
else if(s[p].getNetworkscore()<=81.9)
a[i]=3.0;
else if(s[p].getNetworkscore()<=84.9)
a[i]=3.3;
else if(s[p].getNetworkscore()<=89.9)
a[i]=3.7;
else
a[i]=4.0;
else
if(s[p].getNetworkscore()>=68)
a[i]=2.0;
else if(s[p].getNetworkscore()>=66)
a[i]=1.7;
else if(s[p].getNetworkscore()>=64)
a[i]=1.5;
else if(s[p].getNetworkscore()>=60)
a[i]=1.0;
else
a[i]=0;
if(i==3)
if(s[p].getDatabasescore()>=72)
if(s[p].getDatabasescore()<=74.9)
a[i]=2.3;
else if(s[p].getDatabasescore()<=77.9)
a[i]=2.7;
else if(s[p].getDatabasescore()<=81.9)
a[i]=3.0;
else if(s[p].getDatabasescore()<=84.9)
a[i]=3.3;
else if(s[p].getDatabasescore()<=89.9)
a[i]=3.7;
else
a[i]=4.0;
else
if(s[p].getDatabasescore()>=68)
a[i]=2.0;
else if(s[p].getDatabasescore()>=66)
a[i]=1.7;
else if(s[p].getDatabasescore()>=64)
a[i]=1.5;
else if(s[p].getDatabasescore()>=60)
a[i]=1.0;
else
a[i]=0;
if(i==4)
if(s[p].getSoftwarescore()>=72)
if(s[p].getSoftwarescore()<=74.9)
a[i]=2.3;
else if(s[p].getSoftwarescore()<=77.9)
a[i]=2.7;
else if(s[p].getSoftwarescore()<=81.9)
a[i]=3.0;
else if(s[p].getSoftwarescore()<=84.9)
a[i]=3.3;
else if(s[p].getSoftwarescore()<=89.9)
a[i]=3.7;
else
a[i]=4.0;
else
if(s[p].getSoftwarescore()>=68)
a[i]=2.0;
else if(s[p].getSoftwarescore()>=66)
a[i]=1.7;
else if(s[p].getSoftwarescore()>=64)
a[i]=1.5;
else if(s[p].getSoftwarescore()>=60)
a[i]=1.0;
else
a[i]=0;
for(i=0;i<5;i++)
v+=a[i]*g[i];
v=v/16;
v=(double)Math.round(v*100)/100;
if(v>2.0)
flag5=true;
else
flag5=false;
stu.display7();
System.out.println(" 学生学号:"+s[p].getStunumber());
System.out.println(" 学生姓名:"+s[p].getName());
System.out.println(" 1、高等数学成绩绩点:"+a[0]);
System.out.println(" 2、大学英语成绩绩点::"+a[1]);
System.out.println(" 3、计算机网络成绩绩点:"+a[2]);
System.out.println(" 4、数据库成绩绩点:"+a[3]);
System.out.println(" 5、软件工程成绩绩点:"+a[4]);
System.out.println(" 6、你的平均学分绩点为:"+v);
if(flag5==true)
System.out.println(" 你的学分绩点已达到毕业要求!");
else
System.out.println(" 你的学分绩点不满足毕业要求!");
System.out.println(" 是否返回系统主界面:(Y/N) ");
String c;
c=in.next();
if(c.compareTo("Y")==0)
flag6=false;
if(flag6==false&&flag4==false)
break;
break;
case 4:
stu.display3();
flag=false;
break;
以上是关于Java开学测试的主要内容,如果未能解决你的问题,请参考以下文章