zoukankan      html  css  js  c++  java
  • Java考试

      本周一进行了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("*********************************************************** " +
    "石家庄铁道大学软件工程系 " +
    "学生学籍管理系统 2019 版 " +
    "*********************************************************** " +
    "1、 学生考试成绩录入 " +
    "2、 学生考试成绩修改 " +
    "3、 计算学生成绩绩点 " +
    "4、退出学籍管理系统 " +
    "**********************************************************");
    int ch;
    System.out.println("请选择:");
    ch = sc.nextInt();
    }

    public static String input() {

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

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

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

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

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

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

    public static void six() {
    String b;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getStunumber()+" "+
    " 学生姓名:"+a[t].getName()+" "+
    " 高等数学成绩:"+a[t].getMathematicsscore()+" "+
    " 大学英语成绩:"+a[t].getEnglishiscore()+" "+
    " 计算机网络成绩:"+a[t].getNetworkscore()+" "+
    " 数据库成绩:"+a[t].getDatabasescore()+" "+
    " 软件工程成绩:"+a[t].getSoftwarescore()+" "+
    "*************************************************************** " +
    "该学生的成绩已录入,是否提交(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("*********************************************************** " +
    "石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    "学生考试成绩修改界面 " +
    "*********************************************************** " +
    "请输入学生学号:XXXXXXXX " +
    "**********************************************************");
    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("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 1,高等数学成绩:"+a[t].getmathematicsscore()+" "+
    " 2,大学英语成绩:"+a[t].getenglishiscore()+" "+
    " 3,计算机网络成绩:"+a[t].getnetworkscore()+" "+
    " 4, 数据库成绩:"+a[t].getdatabasescore()+" "+
    " 5,软件工程成绩:"+a[t].getsoftwarescore()+" "+
    "**************************************************************** \n");
    f=sc.nextInt();
    return f;
    }

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

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

    public static void threeteen() {
    double b=0;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 请输入修改后的计算机网络成绩:");
    b=sc.nextDouble();
    jl=a[t].getnetworkscore();
    a[t].setnetworkscore(b);
    sixteen();
    }
    public static void fourteen() {
    double b=0;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 请输入修改后的数据库成绩:");
    b=sc.nextDouble();
    jl=a[t].getdatabasescore();
    a[t].setdatabasescore(b);
    sixteen();
    }
    public static void fifteen() {
    double b=0;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 请输入修改后的软件工程成绩:");
    b=sc.nextDouble();
    jl=a[t].getsoftwarescore();
    a[t].setsoftwarescore(b);
    sixteen();
    }
    public static void sixteen() {
    String b;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩录入 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 高等数学成绩:"+a[t].getmathematicsscore()+" "+
    " 大学英语成绩:"+a[t].getenglishiscore()+" "+
    " 计算机网络成绩:"+a[t].getnetworkscore()+" "+
    " 数据库成绩:"+a[t].getdatabasescore()+" "+
    " 软件工程成绩:"+a[t].getsoftwarescore()+" "+
    "该学生的成绩已修改完毕,是否提交(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("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩基点计算 " +
    "**************************************************************** " +
    " 请输入学生学号(学号为八位): "+
    "****************************************************************");
    str=sc.next();
    return str;

    }

    public static void show() {
    String b;
    System.out.println("*************************************************************** " +
    " 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 " +
    " 学生考试成绩基点计算 " +
    "**************************************************************** " +
    " 学生学号:"+a[t].getstunumber()+" "+
    " 学生姓名:"+a[t].getname()+" "+
    " 1,高等数学成绩基点:"+r[0]+" "+
    " 2,大学英语成绩基点:"+r[1]+" "+
    " 3,计算机网络成绩基点:"+r[2]+" "+
    " 4, 数据库成绩基点:"+r[3]+" "+
    " 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("*************************************************************** " +
    "谢谢使用石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "+
    " 制作人:薛秋香 "+
    "****************************************************************");
    }


    }

    设计思路


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

  • 相关阅读:
    关于多工序生产中损耗的计算
    ERP相关术语
    linux下如何挂载U盘
    linux boot下的文件
    MPLS简述
    BGP
    linux添加新磁盘
    列表的方法
    python之列表
    python之模块初识-os模块
  • 原文地址:https://www.cnblogs.com/xueqiuxiang/p/11514601.html
Copyright © 2011-2022 走看看