zoukankan      html  css  js  c++  java
  • java课堂测试

     
     package  作业2;

    //
    信1805-1 杨一帆 20183608 public class ScoreInformation1 { private String stunumber; private String name; private double mathematicsscore=4; private double englishiscore=3; private double networkscore=4; private double databasescore=3; private double softwarescore=2; public ScoreInformation1() { super(); // TODO Auto-generated constructor stub } public ScoreInformation1(String stunumber, String name, double mathematicsscore, double englishiscore, double networkscore, double databasescore, double softwarescore) { super(); this.stunumber = stunumber; this.name = name; this.mathematicsscore = mathematicsscore; this.englishiscore = englishiscore; this.networkscore = networkscore; this.databasescore = databasescore; this.softwarescore = 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; } } package 作业2; import java.util.Scanner; public class ScoreManagement1 { public static void main(String[] args) { ScoreInformation1[] stu =new ScoreInformation1[5]; stu[0]=new ScoreInformation1("20183606", "晏雯慧", 4, 3, 4, 3, 2); stu[1]=new ScoreInformation1("20183607", "徐姣美", 4, 3, 4, 3, 2); stu[2]=new ScoreInformation1("20183608", "杨一帆", 4, 3, 4, 3, 2); stu[3]=new ScoreInformation1("20183609", "胡海靖", 4, 3, 4, 3, 2); stu[4]=new ScoreInformation1("20183610", "冯静妃", 4, 3, 4, 3, 2); //ScoreManagement1 S1=new ScoreManagement1(); exit(stu); } String name; static double mathematicsscore; static double englishiscore; static double networkscore; static double databasescore; static double softwarescore; public static void exit(ScoreInformation1[] stu) { 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("************************"); int n; Scanner s=new Scanner(System.in); n=s.nextInt(); if(n==1) { luru(stu); } else if(n==2) { xiugai(stu); } else if(n==3) { jidian(stu); } else if(n==4) { tuichu(stu); } else { System.out.println("该选项不存在"); exit(stu); } } public static void tuichu(ScoreInformation1[] stu) { System.out.println("******************"); System.out.println("谢谢使用石家庄铁道大学软件工程系学生学籍管理系统 2019 版"); System.out.println("制作人:杨一帆"); System.out.println("*******************"); } public static void luru(ScoreInformation1[] stu) { int flag=1; System.out.println("*********************"); System.out.println("石家庄铁道大学软件工程系" ); System.out.println( "学生学籍管理系统 2019 版"); System.out.println("**********************"); System.out.println("请输入学生的学号"); System.out.println("************************"); Scanner sc=new Scanner(System.in); String number=sc.nextLine(); for(int i=0;i<5;i++) { if(number.equals(stu[i].getstunumber())) { System.out.println("*************"); System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版"); System.out.println("学生考试成绩录入"); System.out.println("*************"); System.out.println("学生学号"+stu[i].getstunumber()); System.out.println("学生姓名:"+stu[i].getname()); System.out.println("请输入高数成绩"); System.out.println("**********************"); Scanner s1=new Scanner(System.in); double mathematicsscore=s1.nextDouble(); System.out.println("请输入大学英语成绩"); Scanner s2=new Scanner(System.in); double englishiscore=s2.nextDouble(); System.out.println("请输入计算机网络成绩"); Scanner s3=new Scanner(System.in); double networkscore=s3.nextDouble(); System.out.println("请输入数据库成绩"); Scanner s4=new Scanner(System.in); double databasescore=s4.nextDouble(); System.out.println("请输入软件工程的成绩"); Scanner s5=new Scanner(System.in); double softwarescore=s5.nextDouble(); System.out.println("*************"); System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版"); System.out.println("学生考试成绩录入"); System.out.println("*************"); System.out.println("学生学号"+stu[i].getstunumber()); System.out.println("学生姓名:"+stu[i].getname()); System.out.println("高数成绩"+mathematicsscore); System.out.println("英语成绩"+englishiscore); System.out.println("计算机网络成绩"+networkscore); System.out.println("数据库成绩"+databasescore); System.out.println("软件工程成绩"+softwarescore); System.out.println("该学生成绩已录入完毕,是否提交(Y/N)"); System.out.println("*******************************"); Scanner s6=new Scanner(System.in); String a=s6.next(); if(a.equals("Y")) { stu[i].setmathematicsscore(mathematicsscore); stu[i].setenglishiscore(englishiscore); stu[i].setnetworkscore(networkscore); stu[i].setsoftwarescore(softwarescore); stu[i].setdatabasescore(databasescore); exit(stu); } else { System.out.println("重新返回成绩录入界面"); exit(stu); } flag=1; } } if(flag==0) { System.out.println("没有这位学生"); exit(stu); } } public static void xiugai(ScoreInformation1[] stu) { System.out.println("*******************************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩修改界面 "); System.out.println("*******************************************"); System.out.println(" 请输入学生学号 "); System.out.println("*******************************************"); Scanner a1=new Scanner(System.in); String number1 = a1.next(); int t = 0; for(int i=0;i<5;i++) { if(stu[i].getstunumber().equals(number1)) { t=i; } } System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+stu[t].getmathematicsscore()); System.out.println("2、英语成绩"+stu[t].getenglishiscore()); System.out.println("3、计算机网络成绩"+stu[t].getnetworkscore()); System.out.println("4、数据库成绩"+stu[t].getdatabasescore()); System.out.println("5、软件工程成绩"+stu[t].getsoftwarescore()); System.out.println("请输入要修改的序号"); System.out.println("***********************************"); int a; Scanner s8=new Scanner(System.in); a=s8.nextInt(); if(a==1) { System.out.println("************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("请输入修改后的高数成绩"); Scanner a2=new Scanner(System.in); mathematicsscore=a2.nextDouble(); stu[t].setmathematicsscore(mathematicsscore); System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+mathematicsscore); System.out.println("2、英语成绩"+stu[t].getenglishiscore()); System.out.println("3、计算机网络成绩"+stu[t].getnetworkscore()); System.out.println("4、数据库成绩"+stu[t].getdatabasescore()); System.out.println("5、软件工程成绩"+stu[t].getsoftwarescore()); System.out.println("学生成绩修改完成,是否提交(Y/N)"); System.out.println("***********************************"); Scanner a3=new Scanner(System.in); String e=a3.next(); if(a3.equals("Y")) { stu[t].setmathematicsscore(mathematicsscore); stu[t].setenglishiscore(englishiscore); stu[t].setnetworkscore(networkscore); stu[t].setdatabasescore(databasescore); stu[t].setsoftwarescore(softwarescore); exit(stu); } else { exit(stu); } } else if(a==2) { System.out.println("************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("请输入修改后的英语成绩"); Scanner a4=new Scanner(System.in); englishiscore=a4.nextDouble(); stu[t].setenglishiscore(englishiscore); System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+stu[t].getmathematicsscore()); System.out.println("2、英语成绩"+englishiscore); System.out.println("3、计算机网络成绩"+stu[t].getnetworkscore()); System.out.println("4、数据库成绩"+stu[t].getdatabasescore()); System.out.println("5、软件工程成绩"+stu[t].getsoftwarescore()); System.out.println("学生成绩修改完成,是否提交"); System.out.println("***********************************"); Scanner a3=new Scanner(System.in); String e=a3.next(); if(a3.equals("Y")) { stu[t].setmathematicsscore(mathematicsscore); stu[t].setenglishiscore(englishiscore); stu[t].setnetworkscore(networkscore); stu[t].setdatabasescore(databasescore); stu[t].setsoftwarescore(softwarescore); exit(stu); } else { exit(stu); } } else if(a==3) { System.out.println("************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("请输入修改后计算机网络的成绩"); Scanner a5=new Scanner(System.in); networkscore=a5.nextDouble(); stu[t].setnetworkscore(networkscore); System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+stu[t].getmathematicsscore()); System.out.println("2、英语成绩"+stu[t].getenglishiscore()); System.out.println("3、计算机网络成绩"+networkscore); System.out.println("4、数据库成绩"+stu[t].getdatabasescore()); System.out.println("5、软件工程成绩"+stu[t].getsoftwarescore()); System.out.println("学生成绩修改完成,是否提交"); System.out.println("***********************************"); Scanner a3=new Scanner(System.in); String e=a3.next(); if(a3.equals("Y")) { stu[t].setmathematicsscore(mathematicsscore); stu[t].setenglishiscore(englishiscore); stu[t].setnetworkscore(networkscore); stu[t].setdatabasescore(databasescore); stu[t].setsoftwarescore(softwarescore); exit(stu); } else { exit(stu); } } else if(a==4) { System.out.println("************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("请输入修改后的数据库成绩"); Scanner a6=new Scanner(System.in); databasescore=a6.nextDouble(); stu[t].setdatabasescore(databasescore); System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+stu[t].getmathematicsscore()); System.out.println("2、英语成绩"+stu[t].getenglishiscore()); System.out.println("3、计算机网络成绩"+stu[t].getnetworkscore()); System.out.println("4、数据库成绩"+databasescore); System.out.println("5、软件工程成绩"+stu[t].getsoftwarescore()); System.out.println("学生成绩修改完成,是否提交"); System.out.println("***********************************"); Scanner a3=new Scanner(System.in); String e=a3.next(); if(a3.equals("Y")) { stu[t].setmathematicsscore(mathematicsscore); stu[t].setenglishiscore(englishiscore); stu[t].setnetworkscore(networkscore); stu[t].setdatabasescore(databasescore); stu[t].setsoftwarescore(softwarescore); exit(stu); } else { exit(stu); } } else if(a==5) { System.out.println("************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("请输入修改后的软件工程成绩"); Scanner a7=new Scanner(System.in); softwarescore=a7.nextDouble(); stu[t].setsoftwarescore(softwarescore); System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩录入 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩"+stu[t].getmathematicsscore()); System.out.println("2、英语成绩"+stu[t].getenglishiscore()); System.out.println("3、计算机网络成绩"+stu[t].getnetworkscore()); System.out.println("4、数据库成绩"+stu[t].getdatabasescore()); System.out.println("5、软件工程成绩"+softwarescore); System.out.println("学生成绩修改完成,是否提交"); System.out.println("***********************************"); Scanner a3=new Scanner(System.in); String e=a3.next(); if(a3.equals("Y")) { stu[t].setmathematicsscore(mathematicsscore); stu[t].setenglishiscore(englishiscore); stu[t].setnetworkscore(networkscore); stu[t].setdatabasescore(databasescore); stu[t].setsoftwarescore(softwarescore); exit(stu); } else { exit(stu); } } } public static void jidian(ScoreInformation1[] stu) { System.out.println("**************************************"); System.out.println("石家庄铁道大学软件工程系学生学籍管理系统 2019 版"); System.out.println("学生考试成绩绩点计算界面"); System.out.println("****************************************"); System.out.println("请输入学生学号:"); System.out.println("*****************************************"); int t=0; Scanner s=new Scanner(System.in); String number=s.next(); for(int i=0;i<5;i++) { if(stu[i].getstunumber().equals(number)) { t=i; } } double a=0.0; a= (panduan(stu[t].getmathematicsscore())*4+panduan(stu[t].getenglishiscore())*3+panduan(stu[t].getnetworkscore())*4+panduan(stu[t].getdatabasescore())*3+panduan(stu[t].getsoftwarescore())*2)/16; System.out.println("***********************************"); System.out.println(" 石家庄铁道大学软件工程系学生学籍管理系统 2019 版 "); System.out.println(" 学生考试成绩绩点计算界面 "); System.out.println("**********************************"); System.out.println("学生学号:"+stu[t].getstunumber()); System.out.println("学生姓名:"+stu[t].getname()); System.out.println("1、高数成绩绩点"+panduan(stu[t].getmathematicsscore())); System.out.println("2、英语成绩绩点"+panduan(stu[t].getenglishiscore())); System.out.println("3、计算机网络成绩绩点"+panduan(stu[t].getnetworkscore())); System.out.println("4、数据库成绩绩点"+panduan(stu[t].getdatabasescore())); System.out.println("5、软件工程成绩绩点"+panduan(stu[t].getsoftwarescore())); System.out.println("你的平均学分绩点为:"+String.format("%.2f", a)); System.out.println("是否返回主界面(Y/N)"); System.out.println("***********************************"); Scanner s9=new Scanner(System.in); String d=s9.next(); if(d.equals("Y")) { exit(stu); } } public static double panduan(double f) { double a = 0.0 ; if(f<60) { a=0.0; } if(f>=60&&f<=63.9) { a=1.0; } if(f>=64&&f<=65.9) { a=1.5; } if(f>=66&&f<=67.9) { a=1.7; } if(f>=68&&f<=71.9) { a=2.0; } if(f>=72&&f<=74.9) { a=2.3; } if(f>=75&&f<=77.9) { a=2.7; } if(f>=78&&f<=81.9) { a=3.0; } if(f>=82&&f<=84.9) { a=3.3; } if(f>=85&&f<=89.9) { a=3.7; } if(f>=90) { a=4.0; } return a; } }

        

    写这次的测试上课的时候一直在写,但是不会用数组的形式来写,只是用了一个人的成绩,然后过了一天的下午,开始学习了数组,又开始重新学习,从3点写到了7点,这是小学期之后又一次长时间的编程,java比c++和c感觉要复杂一点,这个编程要多加练习,那些个固定的格式要熟记在脑子里面,随着代码的变长,要学会一点一点,要及时的运行程序,及时发现错误,这个测试要我知道要好好学习java,不能和别人的差距越来越大,认真细心,是编程最重要的方法了吧;

  • 相关阅读:
    转------深入理解--Java按值传递和按引用传递
    排序算法 -------未完待续
    eclipse智能提示报错(to avoid the message, disable the...)
    关于hashcode 和 equals 的内容总结
    随笔 软件设计师 -----------考后总结
    wpf 中用 C# 代码创建 PropertyPath ,以对间接目标进行 Storyboard 动画.
    AvaloniaUI体验
    wpf 通过为DataGrid所绑定的数据源类型的属性设置Attribute改变DataGrid自动生成列的顺序
    wpf 在不同DPI下如何在DrawingVisual中画出清晰的图形
    基于libcurl实现REST风格http/https的get和post
  • 原文地址:https://www.cnblogs.com/1234yyf/p/11508346.html
Copyright © 2011-2022 走看看