• Java小测代码及截图


    源代码

    //20183584
    //刘瑞阳
    //信1805-3班
    package scoreinformation;
    import java.util.*;
    import java.text.DecimalFormat;
    import java.util.Scanner;
    import scoreinformation.ScoreInformation;
    public class ScoreManagement {
    static Scanner in=new Scanner(System.in);
    static void display() {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系 ");
    System.out.println("\t\t学生学籍管理系统 2019 版 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t1、 学生考试成绩录入 ");
    System.out.println("\t\t2、 学生考试成绩修改 ");
    System.out.println("\t\t3、 计算学生成绩绩点 ");
    System.out.println("\t\t4、退出学籍管理系统 ");
    System.out.println("***********************************************************");
    }
    static void displayexit() {
    System.out.println("***********************************************************");
    System.out.println("\t\t谢谢使用石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t制作人:刘瑞阳 ");
    System.out.println("***********************************************************");
    System.exit(0);
    }

    static void displayscorescan() {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩录入 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t请输入学生学号:XXXXXXXX");
    System.out.println("***********************************************************");
    scorescan();
    }
    static void scorescan() {

    String str=in.next();
    int flag=0;
    for(int i=0;i<5;i++) {
    if(str.equals(stu[i].getstunumber())) {
    System.out.println("学生信息:"+"姓名:"+stu[i].getname()+","+"学号:"+stu[i].getstunumber());
    displayscorescan2(i);
    flag=1;
    }
    }
    if(flag==0) {
    System.out.println("没有此学生!");
    displayscorescan();
    }
    }
    static void displayscorescan2(int a) {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩录入 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t学生学号: "+stu[a].getstunumber());
    System.out.println("\t\t学生姓名: "+stu[a].getname());
    System.out.println("\t\t请输入高等数学成绩: ");
    stu[a].setmathematicsscore(in.nextDouble());
    System.out.println("\t\t高等数学成绩:"+stu[a].getmathematicsscore());
    System.out.println("\t\t请输入大学英语成绩: ");
    stu[a].setenglishiscore(in.nextDouble());
    System.out.println("\t\t大学英语成绩:"+stu[a].getenglishiscore());
    System.out.println("\t\t请输入计算机网络成绩: ");
    stu[a].setnetworkscore(in.nextDouble());
    System.out.println("\t\t计算机网络成绩:"+stu[a].getnetworkscore());
    System.out.println("\t\t请输入数据库成绩: ");
    stu[a].setdatabasescore(in.nextDouble());
    System.out.println("\t\t数据库成绩:"+stu[a].getdatabasescore());
    System.out.println("\t\t请输入软件工程成绩: ");
    stu[a].setsoftwarescore(in.nextDouble());

    System.out.println("\t\t软件工程成绩:"+stu[a].getsoftwarescore());

    System.out.println("该学生成绩已录入完毕,是否提交(Y/N)");
    String tijiao=in.next();
    //System.out.println(tijiao);
    if(tijiao.equals("Y")) {
    //display();
    }
    else {
    stu[a].setmathematicsscore(0);
    stu[a].setenglishiscore(0);
    stu[a].setnetworkscore(0);
    stu[a].setdatabasescore(0);
    stu[a].setsoftwarescore(0);
    displayscorescan();
    }
    System.out.println("***********************************************************");
    }
    static void update() {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩修改界面 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t请输入学生学号: \t");
    System.out.println("***********************************************************");

    String str2=in.next();
    int flag2=0;
    for(int i=0;i<5;i++) {
    if(str2.equals(stu[i].getstunumber())) {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩录入 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t学生学号: "+stu[i].getstunumber());
    System.out.println("\t\t学生姓名: "+stu[i].getname());
    System.out.println("\t\t1、高等数学成绩:"+stu[i].getmathematicsscore());
    System.out.println("\t\t2、大学英语成绩:"+stu[i].getenglishiscore());
    System.out.println("\t\t3、计算机网络成绩:"+stu[i].getnetworkscore());
    System.out.println("\t\t4、数据库成绩:"+stu[i].getdatabasescore());
    System.out.println("\t\t5、软件工程成绩:"+stu[i].getsoftwarescore());
    System.out.println("请输入要修改科目对应的序号:");
    int b=in.nextInt();
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩录入 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t学生学号: "+stu[i].getstunumber());
    System.out.println("\t\t学生姓名: "+stu[i].getname());
    double memorymath=stu[i].getmathematicsscore();
    double memoryenglish=stu[i].getenglishiscore();
    double memorynet=stu[i].getnetworkscore();
    double memorydata=stu[i].getdatabasescore();
    double memorysoft=stu[i].getsoftwarescore();
    switch(b) {
    case 1:System.out.println("请输入修改后的高等数学的成绩:");
    stu[i].setmathematicsscore(in.nextDouble());
    System.out.println("***********************************************************");
    break;
    case 2:System.out.println("请输入修改后的大学英语的成绩:");
    stu[i].setenglishiscore(in.nextDouble());
    System.out.println("***********************************************************");
    break;
    case 3:System.out.println("请输入修改后的计算机网络的成绩:");
    stu[i].setnetworkscore(in.nextDouble());
    System.out.println("***********************************************************");
    break;
    case 4:System.out.println("请输入修改后的数据库的成绩:");
    stu[i].setdatabasescore(in.nextDouble());
    System.out.println("***********************************************************");
    break;
    case 5:System.out.println("请输入修改后的软件工程的成绩:");

    stu[i].setsoftwarescore(in.nextDouble());

    System.out.println("***********************************************************");
    break;
    }
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩录入 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t学生学号: "+stu[i].getstunumber());
    System.out.println("\t\t学生姓名: "+stu[i].getname());
    System.out.println("\t\t高等数学成绩:"+stu[i].getmathematicsscore());
    System.out.println("\t\t大学英语成绩:"+stu[i].getenglishiscore());
    System.out.println("\t\t计算机网络成绩:"+stu[i].getnetworkscore());
    System.out.println("\t\t数据库成绩:"+stu[i].getdatabasescore());
    System.out.println("\t\t软件工程成绩:"+stu[i].getsoftwarescore());
    System.out.println("\t\t该学生成绩已修改完毕,是否提交(Y/N) ");
    String tijiao=in.next();
    if(tijiao.equals("Y")) {
    //display();
    }
    else {
    if(b==1)
    stu[i].setmathematicsscore(memorymath);
    if(b==2)
    stu[i].setenglishiscore(memoryenglish);
    if(b==3)
    stu[i].setnetworkscore(memorynet);
    if(b==4)
    stu[i].setdatabasescore(memorydata);
    if(b==5)
    stu[i].setsoftwarescore(memorysoft);
    update();
    }
    System.out.println("***********************************************************");
    flag2=1;
    }
    }
    if(flag2==0) {
    System.out.println("该学生不存在!");
    update();
    }
    }
    static double mathjd(int i) {
    double mathjd=0;
    if(stu[i].getmathematicsscore()>=90)
    mathjd=4.0;
    if(stu[i].getmathematicsscore()<=89.9&&stu[i].getmathematicsscore()>85)
    mathjd=3.7;
    if(stu[i].getmathematicsscore()<=84.9&&stu[i].getmathematicsscore()>82)
    mathjd=3.2;
    if(stu[i].getmathematicsscore()<=81.9&&stu[i].getmathematicsscore()>78)
    mathjd=3.0;
    if(stu[i].getmathematicsscore()<=77.9&&stu[i].getmathematicsscore()>75)
    mathjd=2.7;
    if(stu[i].getmathematicsscore()<=74.9&&stu[i].getmathematicsscore()>72)
    mathjd=2.3;
    if(stu[i].getmathematicsscore()<=71.9&&stu[i].getmathematicsscore()>68)
    mathjd=2.0;
    if(stu[i].getmathematicsscore()<=67.9&&stu[i].getmathematicsscore()>66)
    mathjd=1.7;
    if(stu[i].getmathematicsscore()<=65.9&&stu[i].getmathematicsscore()>64)
    mathjd=1.5;
    if(stu[i].getmathematicsscore()<=63.9&&stu[i].getmathematicsscore()>=60)
    mathjd=1.0;
    if(stu[i].getmathematicsscore()<60)
    mathjd=0;
    return mathjd;
    }
    static double englishjd(int i) {
    double englishjd=0;
    if(stu[i].getenglishiscore()>=90)
    englishjd=4.0;
    if(stu[i].getenglishiscore()<=89.9&&stu[i].getenglishiscore()>85)
    englishjd=3.7;
    if(stu[i].getenglishiscore()<=84.9&&stu[i].getenglishiscore()>82)
    englishjd=3.2;
    if(stu[i].getenglishiscore()<=81.9&&stu[i].getenglishiscore()>78)
    englishjd=3.0;
    if(stu[i].getenglishiscore()<=77.9&&stu[i].getenglishiscore()>75)
    englishjd=2.7;
    if(stu[i].getenglishiscore()<=74.9&&stu[i].getenglishiscore()>72)
    englishjd=2.3;
    if(stu[i].getenglishiscore()<=71.9&&stu[i].getenglishiscore()>68)
    englishjd=2.0;
    if(stu[i].getenglishiscore()<=67.9&&stu[i].getenglishiscore()>66)
    englishjd=1.7;
    if(stu[i].getenglishiscore()<=65.9&&stu[i].getenglishiscore()>64)
    englishjd=1.5;
    if(stu[i].getenglishiscore()<=63.9&&stu[i].getenglishiscore()>=60)
    englishjd=1.0;
    if(stu[i].getenglishiscore()<60)
    englishjd=0;
    return englishjd;
    }
    static double netjd(int i) {
    double netjd=0;
    if(stu[i].getnetworkscore()>=90)
    netjd=4.0;
    if(stu[i].getnetworkscore()<=89.9&&stu[i].getnetworkscore()>85)
    netjd=3.7;
    if(stu[i].getnetworkscore()<=84.9&&stu[i].getnetworkscore()>82)
    netjd=3.2;
    if(stu[i].getnetworkscore()<=81.9&&stu[i].getnetworkscore()>78)
    netjd=3.0;
    if(stu[i].getnetworkscore()<=77.9&&stu[i].getnetworkscore()>75)
    netjd=2.7;
    if(stu[i].getnetworkscore()<=74.9&&stu[i].getnetworkscore()>72)
    netjd=2.3;
    if(stu[i].getnetworkscore()<=71.9&&stu[i].getnetworkscore()>68)
    netjd=2.0;
    if(stu[i].getnetworkscore()<=67.9&&stu[i].getnetworkscore()>66)
    netjd=1.7;
    if(stu[i].getnetworkscore()<=65.9&&stu[i].getnetworkscore()>64)
    netjd=1.5;
    if(stu[i].getnetworkscore()<=63.9&&stu[i].getnetworkscore()>=60)
    netjd=1.0;
    if(stu[i].getnetworkscore()<60)
    netjd=0;
    return netjd;
    }
    static double datajd(int i) {
    double datajd=0;
    if(stu[i].getdatabasescore()>=90)
    datajd=4.0;
    if(stu[i].getdatabasescore()<=89.9&&stu[i].getdatabasescore()>85)
    datajd=3.7;
    if(stu[i].getdatabasescore()<=84.9&&stu[i].getdatabasescore()>82)
    datajd=3.2;
    if(stu[i].getdatabasescore()<=81.9&&stu[i].getdatabasescore()>78)
    datajd=3.0;
    if(stu[i].getdatabasescore()<=77.9&&stu[i].getdatabasescore()>75)
    datajd=2.7;
    if(stu[i].getdatabasescore()<=74.9&&stu[i].getdatabasescore()>72)
    datajd=2.3;
    if(stu[i].getdatabasescore()<=71.9&&stu[i].getdatabasescore()>68)
    datajd=2.0;
    if(stu[i].getdatabasescore()<=67.9&&stu[i].getdatabasescore()>66)
    datajd=1.7;
    if(stu[i].getdatabasescore()<=65.9&&stu[i].getdatabasescore()>64)
    datajd=1.5;
    if(stu[i].getdatabasescore()<=63.9&&stu[i].getdatabasescore()>=60)
    datajd=1.0;
    if(stu[i].getdatabasescore()<60)
    datajd=0;
    return datajd;
    }
    static double softjd(int i) {
    double softjd=0;
    if(stu[i].getsoftwarescore()>=90)
    softjd=4.0;
    if(stu[i].getsoftwarescore()<=89.9&&stu[i].getsoftwarescore()>85)
    softjd=3.7;
    if(stu[i].getsoftwarescore()<=84.9&&stu[i].getsoftwarescore()>82)
    softjd=3.2;
    if(stu[i].getsoftwarescore()<=81.9&&stu[i].getsoftwarescore()>78)
    softjd=3.0;
    if(stu[i].getsoftwarescore()<=77.9&&stu[i].getsoftwarescore()>75)
    softjd=2.7;
    if(stu[i].getsoftwarescore()<=74.9&&stu[i].getsoftwarescore()>72)
    softjd=2.3;
    if(stu[i].getsoftwarescore()<=71.9&&stu[i].getsoftwarescore()>68)
    softjd=2.0;
    if(stu[i].getsoftwarescore()<=67.9&&stu[i].getsoftwarescore()>66)
    softjd=1.7;
    if(stu[i].getsoftwarescore()<=65.9&&stu[i].getsoftwarescore()>64)
    softjd=1.5;
    if(stu[i].getsoftwarescore()<=63.9&&stu[i].getsoftwarescore()>=60)
    softjd=1.0;
    if(stu[i].getsoftwarescore()<60)
    softjd=0;
    return softjd;
    }
    static double averagejd(int k) {
    double ave,he1;
    he1=mathjd(k)*4+englishjd(k)*3+netjd(k)*4+datajd(k)*3+softjd(k)*2;
    return he1/16;
    }
    static void displayjd() {
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩绩点计算界面 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t请输入学生学号:XXXXXXXXXXXX ");
    System.out.println("***********************************************************");
    String str=in.next();
    boolean b1=true;
    DecimalFormat df = new DecimalFormat("#.00");
    for(int i=0;i<5;i++) {
    if(str.equals(stu[i].getstunumber())) {
    b1=false;
    System.out.println("***********************************************************");
    System.out.println("\t\t石家庄铁道大学软件工程系学生学籍管理系统 2019 版 ");
    System.out.println("\t\t学生考试成绩绩点计算界面 ");
    System.out.println("***********************************************************");
    System.out.println("\t\t学生学号:"+stu[i].getstunumber());
    System.out.println("\t\t学生姓名:"+stu[i].getname());
    System.out.println("\t\t高等数学成绩绩点:"+mathjd(i));
    System.out.println("\t\t大学英语成绩绩点:"+englishjd(i));
    System.out.println("\t\t计算机网络成绩绩点:"+netjd(i));
    System.out.println("\t\t数据库成绩绩点:"+datajd(i));
    System.out.println("\t\t软件工程成绩绩点:"+softjd(i));
    System.out.print("\t\t你的平均学分绩点:");
    double ave2=averagejd(i);
    System.out.println(df.format(ave2));
    if(averagejd(i)>=2) {
    System.out.println("\t\t提示信息:你的学分绩点已达到毕业要求! ");
    }
    else {
    System.out.println("\t\t提示信息:你的学分绩点不满足毕业要求!");
    }
    System.out.println("\t\t该学生成绩已修改完毕,是否提交(Y/N)");
    String tijiao=in.next();
    if(tijiao.equals("Y")) {
    display();
    }
    else {}
    }
    }
    if(b1) {
    System.out.println("没有此学生!");
    displayjd();
    }

    }
    static ScoreInformation[] stu=new ScoreInformation[10];
    public static void main(String[] args) {
    for(int i=0;i<10;i++)
    stu[i]=new ScoreInformation();
    stu[0].setstunumber("20183584");stu[0].setname("刘瑞阳");/*stu[0].setmathematicsscore(99);
    stu[0].setenglishscore(98);stu[0].setnetworkscore(97);stu[0].setdatabasescore(96);
    stu[0].setsoftwarescore(99);*/
    stu[1].setstunumber("20183583");stu[1].setname("张志伟");/*stu[1].setmathematicsscore(99);
    stu[1].setenglishscore(98);stu[1].setnetworkscore(97);stu[1].setdatabasescore(96);
    stu[1].setsoftwarescore(99);*/
    stu[2].setstunumber("20183585");stu[2].setname("刘云天");/*stu[2].setmathematicsscore(99);
    stu[2].setenglishscore(98);stu[2].setnetworkscore(97);stu[2].setdatabasescore(96);
    stu[2].setsoftwarescore(99);*/
    stu[3].setstunumber("20183500");stu[3].setname("赵士通");/*stu[3].setmathematicsscore(99);
    stu[3].setenglishscore(98);stu[3].setnetworkscore(97);stu[3].setdatabasescore(96);
    stu[3].setsoftwarescore(99);*/
    stu[4].setstunumber("20182600");stu[4].setname("马小");/*stu[4].setmathematicsscore(99);
    stu[4].setenglishscore(98);stu[4].setnetworkscore(97);stu[4].setdatabasescore(96);
    stu[4].setsoftwarescore(99);*/
    boolean b1=true;
    while(b1) {
    display();
    int num=in.nextInt();
    switch(num) {
    case 1:displayscorescan();
    break;
    case 2:update();
    break;
    case 3:displayjd();
    break;
    case 4:displayexit();
    break;
    }
    }
    }

    }

    //20183584
    //刘瑞阳
    //信1805-3班
    package 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 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;
    }

    }

    截图:

     

     

     

     

     

     

    思路:将student信息定义到一个类里,再把学籍成绩定义成另一个类。实现不同功能的逐步进行。

  • 相关阅读:
    JSON对象和字符串之间的相互转换
    php小数取整的方法
    Vim之Nerd Tree杂草帮助
    PHP获取汉字拼音首字母
    chmod 变更文件或目录的权限
    grep
    tar
    Linux下socket编程 多线程 进程超时阻塞、卡死问题定位
    一些Lambda表达式的学习
    读高性能MySQL的笔记
  • 原文地址:https://www.cnblogs.com/aiyyue/p/11515524.html
Copyright © 2020-2023  润新知