加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java课堂测试样卷-----简易学籍管理系统

发布时间:2020-12-15 07:47:58 所属栏目:Java 来源:网络整理
导读:程序设计思路:分别建立两个类:ScoreInformation类(用来定义学生的基本信息以及设置set和get函数)ScoreManagement类(用来定义实现学生考试成绩录入,考试成绩修改,绩点计算等功能的函数)和一个主函数Text类 (通过输入的数字选项进行功能的实现,因为退

程序设计思路:分别建立两个类:ScoreInformation类(用来定义学生的基本信息以及设置set和get函数)ScoreManagement类(用来定义实现学生考试成绩录入,考试成绩修改,绩点计算等功能的函数)和一个主函数Text类 (通过输入的数字选项进行功能的实现,因为退出系统代码量极少,所以在主函数中实现此功能)

程序源代码及注释

ScoreInformation类:

 1 //信1805-3 20183658 王兵兵
 2 package adc;
 3 
 4 public class ScoreInformation 
 5 {
 6         private String stunumber;                   //学生学号
 7         private String name;                        //学生姓名
 8         private double mathematicsscore;            //高等数学
 9         private double englishscore;                //大学英语
10         private double networkscore;                //计算机网络
11         private double databasescore;               //数据库
12         private double softwarescore;                //软件工程
13         ScoreInformation(String stunumber,String name,double mathematicsscore,double englishscore,double networkscore,double databasescore,double softwarescore)
14         {  //通过构造函数默认赋值
15             this.stunumber=stunumber;
16             this.name=name;
17             this.mathematicsscore=mathematicsscore;
18             this.englishscore=englishscore;
19             this.networkscore=networkscore;
20             this.databasescore=databasescore;
21             this.softwarescore=softwarescore;
22         }
23         public void setstunumber(String stunumber)              //对学生的学号进行赋值操作
24         {
25             this.stunumber=stunumber;
26         }
27         public void setname(String name)                   //对学生的姓名进行赋值操作
28         {
29             this.name=name;
30         }
31         public void setmathematicsscore(double mathematicsscore)         //对学生的高等数学成绩进行赋值操作
32         {
33             this.mathematicsscore=mathematicsscore;
34         }
35         public void setenglishscore(double englishscore)                //对学生的大学英语成绩进行赋值操作
36         {
37             this.englishscore=englishscore;
38         }
39         public void setnetworkscore(double networkscore)                 //对学生的计算机网络成绩进行赋值操作
40         {
41             this.networkscore=networkscore;
42         }
43         public void setdatabasescore(double databasescore)             //对学生的数据库成绩进行赋值操作
44         {
45             this.databasescore=databasescore;
46         }
47         public void setsoftwarescore(double softwarescore)             //对学生的软件工程成绩进行赋值操作
48         {
49             this.softwarescore=softwarescore;
50         }
51         public String getstunumber()           //返回学生的学号
52         {
53             return this.stunumber;
54         }
55         public String getname()                  //返回学生的姓名
56         {
57             return this.name;
58         }
59         public double getmathematicsscore()         //返回学生的高等数学成绩
60         {
61             return this.mathematicsscore;
62         }
63         public double getenglishscore()               //返回学生的大学英语成绩
64         {
65             return this.englishscore;
66         }       
67         public double getnetworkscore()              //返回学生的计算机网络成绩
68         {
69             return this.networkscore;
70         }
71         public double getdatabasescore()              //返回学生的数据库成绩
72         {
73             return this.databasescore;
74         }
75         public double getsoftwarescore()              //返回学生的软件工程成绩
76         {
77             return this.softwarescore;
78         }
79 
80 }

?

ScoreManagement类

  1 package adc;
  2 import java.util.Scanner;
  3 public class ScoreMangerment 
  4 {        
  5          int j=0;
  6         Scanner te=new Scanner(System.in);
  7         ScoreInformation[] SI=new ScoreInformation[100];        //定义一个学生学籍信息的数组
  8         ScoreMangerment() 
  9         {   //利用构造函数初始化5个学生的信息
 10             SI[0]=new ScoreInformation("20183658","王兵兵",0);
 11             SI[1]=new ScoreInformation("20183659","张三",0);
 12             SI[2]=new ScoreInformation("20183660","李四",0);
 13             SI[3]=new ScoreInformation("20183661","王无",0);
 14             SI[4]=new ScoreInformation("20183662","李六",0);
 15         }
 16         public void meau()           //输出系统主界面函数
 17         {
 18             System.out.println("********************************************************");
 19             System.out.println("             t石家庄铁道大学软件工程系");
 20             System.out.println("             t学籍管理系统系统2019版");
 21             System.out.println("********************************************************");
 22             System.out.println("                1、学生考试成绩录入");
 23             System.out.println("                2、学生考试成绩修改");
 24             System.out.println("                3、计算学生成绩绩点");
 25             System.out.println("                4、退出学籍管理系统");
 26             System.out.println("********************************************************");
 27        }
 28         public void scorerecord()                 //功能1:实现学生信息的录入
 29         {
 30             System.out.println("********************************************************");
 31             System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
 32             System.out.println("             t考生成绩录入");
 33             System.out.println("********************************************************");
 34             System.out.println("                请输入考生学号:");
 35             System.out.println("********************************************************");
 36              while(!getanswer())      //用来保证学生的输入的学号存在,否则一直输入,直到输入学生学号存在为止
 37              {
 38                  System.out.println("你输入的学号有误或不存在!");
 39                  System.out.println("********************************************************");
 40                  System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
 41                  System.out.println("             t考生成绩录入");
 42                  System.out.println("********************************************************");
 43                  System.out.println("                请输入考生学号:");
 44                  System.out.println("********************************************************");
 45              }
 46              scoreluruPrint1(j);
 47              while(!pandun1())      //输入Y或N时对应的程序操作
 48              {
 49                  scoreluruPrint1(j);      //输入N返回录入界面
 50              }
 51              meau();            //输入Y后返回主界面
 52         }
 53         public Boolean getanswer()     //检查学号是否存在
 54         {   
 55             String a=te.next();
 56             Boolean temp=false;
 57             for(int i=0;i<5;i++)
 58             {  
 59                 if(a.equals(SI[i].getstunumber()))
 60                 {
 61                     temp=true;
 62                     j=i;
 63                     break;
 64                 }
 65             }
 66             return temp;
 67         }
 68         public void scoreluruPrint1(int j)                    //实现学生成绩信息的输入,并且在输入完一科成绩后进行学生信息的更新
 69         {   
 70              System.out.println("********************************************************");
 71              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
 72              System.out.println("             t考生成绩录入");
 73              System.out.println("********************************************************");
 74              System.out.println("                学生学号:"+SI[j].getstunumber());
 75              System.out.println("                学生姓名:"+SI[j].getname());
 76              System.out.println("                请输入高等数学成绩:");
 77              System.out.println("********************************************************");
 78              SI[5]=new ScoreInformation(" "," ",0);
 79              SI[5].setstunumber(SI[j].getstunumber());
 80              SI[5].setname(SI[j].getname());
 81              double temp1=te.nextDouble();
 82              SI[5].setmathematicsscore(temp1);
 83              System.out.println("********************************************************");
 84              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
 85              System.out.println("             t考生成绩录入");
 86              System.out.println("********************************************************");
 87              System.out.println("                学生学号:"+SI[5].getstunumber());
 88              System.out.println("                学生姓名:"+SI[5].getname());
 89              System.out.println("                高等数学成绩 :"+SI[5].getmathematicsscore());
 90              System.out.println("                请输入大学英语成绩:");
 91              System.out.println("********************************************************");
 92              double temp2=te.nextDouble();
 93              SI[5].setenglishscore(temp2);
 94              System.out.println("********************************************************");
 95              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
 96              System.out.println("             t考生成绩录入");
 97              System.out.println("********************************************************");
 98              System.out.println("                学生学号:"+SI[5].getstunumber());
 99              System.out.println("                学生姓名:"+SI[5].getname());
100              System.out.println("                高等数学成绩 :"+SI[5].getmathematicsscore());
101              System.out.println("                大学英语成绩:"+SI[5].getenglishscore());
102              System.out.println("                请输入计算机网络成绩:");
103              System.out.println("********************************************************");
104              double temp3=te.nextDouble();
105              SI[5].setnetworkscore(temp3);
106              System.out.println("********************************************************");
107              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
108              System.out.println("             t考生成绩录入");
109              System.out.println("********************************************************");
110              System.out.println("                学生学号:"+SI[5].getstunumber());
111              System.out.println("                学生姓名:"+SI[5].getname());
112              System.out.println("                高等数学成绩 :"+SI[5].getmathematicsscore());
113              System.out.println("                大学英语成绩:"+SI[5].getenglishscore());
114              System.out.println("                计算机网络成绩:"+SI[5].getnetworkscore());
115              System.out.println("                请输入数据库成绩:");
116              System.out.println("********************************************************");
117              double temp4=te.nextDouble();
118              SI[5].setdatabasescore(temp4);
119              System.out.println("********************************************************");
120              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
121              System.out.println("             t考生成绩录入");
122              System.out.println("********************************************************");
123              System.out.println("                学生学号:"+SI[5].getstunumber());
124              System.out.println("                学生姓名:"+SI[5].getname());
125              System.out.println("                高等数学成绩 :"+SI[5].getmathematicsscore());
126              System.out.println("                大学英语成绩:"+SI[5].getenglishscore());
127              System.out.println("                计算机网络成绩:"+SI[5].getnetworkscore());
128              System.out.println("                数据库成绩:"+SI[5].getdatabasescore());
129              System.out.println("                请输入软件工程成绩:");
130              System.out.println("********************************************************");
131              double temp5=te.nextDouble();
132              SI[5].setsoftwarescore(temp5);
133              System.out.println("********************************************************");
134              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
135              System.out.println("             t考生成绩录入");
136              System.out.println("********************************************************");
137              System.out.println("                学生学号:"+SI[5].getstunumber());
138              System.out.println("                学生姓名:"+SI[5].getname());
139              System.out.println("                高等数学成绩 :"+SI[5].getmathematicsscore());
140              System.out.println("                大学英语成绩:"+SI[5].getenglishscore());
141              System.out.println("                计算机网络成绩:"+SI[5].getnetworkscore());
142              System.out.println("                数据库成绩:"+SI[5].getdatabasescore());
143              System.out.println("                软件工程成绩:"+SI[5].getsoftwarescore());
144              System.out.println("           该学生生成绩已录入完毕,是否提交(Y/N)");
145              System.out.println("********************************************************");
146         }
147         public Boolean pandun1()     //输入Y或N并返回Boolean值
148         {
149             String temp6=te.next();
150             if(temp6.equals("Y"))
151             {
152                 SI[j]=SI[5];
153                 return true;
154             }
155             else
156             {
157                 return false;
158             }
159         }
160         public void modifyscore()      //功能2:实现学生成绩的修改
161         {
162             System.out.println("********************************************************");
163             System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
164             System.out.println("             t考生成绩修改界面");
165             System.out.println("********************************************************");
166             System.out.println("                请输入考生学号:");
167             System.out.println("********************************************************");
168              while(!getanswer())          //通过while 判断输入的学号是否存在
169              {
170                  System.out.println("你输入的学号有误或不存在!");
171                  System.out.println("********************************************************");
172                  System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
173                  System.out.println("             t考生成绩修改界面");
174                  System.out.println("********************************************************");
175                  System.out.println("                请输入考生学号:");
176                  System.out.println("********************************************************");
177              }
178              System.out.println("********************************************************");         //输出学生的全部信息
179              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
180              System.out.println("             t考生成绩录入");
181              System.out.println("********************************************************");
182              System.out.println("                学生学号:"+SI[j].getstunumber());
183              System.out.println("                学生姓名:"+SI[j].getname());
184              System.out.println("              1、高等数学成绩 :"+SI[j].getmathematicsscore());
185              System.out.println("              2、大学英语成绩:"+SI[j].getenglishscore());
186              System.out.println("              3、计算机网络成绩:"+SI[j].getnetworkscore());
187              System.out.println("              4、数据库成绩:"+SI[j].getdatabasescore());
188              System.out.println("              5、软件工程成绩:"+SI[j].getsoftwarescore());
189              System.out.println("********************************************************");
190              modifyspecialscore();    //修改成绩
191              System.out.println("********************************************************");
192              System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
193              System.out.println("             t考生成绩录入");
194              System.out.println("********************************************************");
195              System.out.println("                学生学号:"+SI[6].getstunumber());
196              System.out.println("                学生姓名:"+SI[6].getname());
197              System.out.println("               1、高等数学成绩 :"+SI[6].getmathematicsscore());
198              System.out.println("               2、大学英语成绩:"+SI[6].getenglishscore());
199              System.out.println("               3、计算机网络成绩:"+SI[6].getnetworkscore());
200              System.out.println("               4、数据库成绩:"+SI[6].getdatabasescore());
201              System.out.println("               5、软件工程成绩:"+SI[6].getsoftwarescore());
202              System.out.println("           该学生生成绩已录入完毕,是否提交(Y/N)");
203              System.out.println("********************************************************");
204              while(!pandun2())
205              {
206                  modifyscore() ;
207              }
208               meau();
209         }
210        public void modifyspecialscore()      //修改选定的成绩
211        {
212            SI[6]=new ScoreInformation(" ",0);
213            SI[6]=SI[j];
214            System.out.println("请输入你要修改的成绩对应的数字选项:");
215            int temp7=te.nextInt();
216            if(temp7==1)
217            {
218              System.out.println("********************************************************");
219                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
220                System.out.println("             t考生成绩录入");
221                System.out.println("********************************************************");
222                System.out.println("                学生学号:"+SI[j].getstunumber());
223                System.out.println("                学生姓名:"+SI[j].getname());
224                System.out.println("            请输入修改后高等数学成绩 :");
225                System.out.println("********************************************************");
226                double index1=te.nextDouble();
227                SI[6].setmathematicsscore(index1);
228            }
229            else if(temp7==2)
230            {
231              System.out.println("********************************************************");
232                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
233                System.out.println("             t考生成绩录入");
234                System.out.println("*******************************************************");
235                System.out.println("                学生学号:"+SI[j].getstunumber());
236                System.out.println("                学生姓名:"+SI[j].getname());
237                System.out.println("            请输入修改后大学英语成绩 :");
238                System.out.println("********************************************************");
239                double index2=te.nextDouble();
240                SI[6].setenglishscore(index2);
241            }
242            else if(temp7==3)
243            {
244              System.out.println("********************************************************");
245                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
246                System.out.println("             t考生成绩录入");
247                System.out.println("*******************************************************");
248                System.out.println("                学生学号:"+SI[j].getstunumber());
249                System.out.println("                学生姓名:"+SI[j].getname());
250                System.out.println("            请输入修改后计算机网络成绩 :");
251                System.out.println("********************************************************");
252                double index3=te.nextDouble();
253                SI[6].setnetworkscore(index3);
254            }
255            else if(temp7==4)
256            {
257              System.out.println("********************************************************");
258                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
259                System.out.println("             t考生成绩录入");
260                System.out.println("*******************************************************");
261                System.out.println("                学生学号:"+SI[j].getstunumber());
262                System.out.println("                学生姓名:"+SI[j].getname());
263                System.out.println("            请输入修改后数据库成绩 :");
264                System.out.println("********************************************************");
265                double index4=te.nextDouble();
266                SI[6].setdatabasescore(index4);
267            }
268            else if(temp7==5)
269            {
270              System.out.println("********************************************************");
271                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
272                System.out.println("             t考生成绩录入");
273                System.out.println("*******************************************************");
274                System.out.println("                学生学号:"+SI[j].getstunumber());
275                System.out.println("                学生姓名:"+SI[j].getname());
276                System.out.println("            请输入修改后软件工程成绩 :");
277                System.out.println("********************************************************");
278                double index5=te.nextDouble();
279                SI[6].setsoftwarescore(index5);
280            }
281        }
282        public Boolean pandun2()         //输入Y或N并返回Boolean值
283        {
284            String temp8=te.next();
285            if(temp8.equals("Y"))
286            {
287                SI[j]=SI[6];
288                return true;
289            }
290            else
291            {
292                return false;
293            }
294        }
295        public void calulatescorepoint()        //功能3:计算学生考试成绩对应的绩点
296        {
297         System.out.println("********************************************************");
298         System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
299         System.out.println("             t学生考试成绩绩点计算界面");
300         System.out.println("********************************************************");
301         System.out.println("                      请输入考生学号:");
302         System.out.println("********************************************************");
303            while(!getanswer())
304            {
305                System.out.println("你输入的学号有误或不存在!");
306                System.out.println("********************************************************");
307                System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
308                System.out.println("             t考生成绩录入");
309                System.out.println("********************************************************");
310             System.out.println("                  请输入考生学号:");
311             System.out.println("********************************************************");
312        }
313            System.out.println("********************************************************");
314            System.out.println("    t石家庄铁道大学软件工程系学籍管理2019版");
315            System.out.println("           t学生成绩绩点计算界面");
316            System.out.println("********************************************************");
317            System.out.println("                   学生学号:"+SI[j].getstunumber());
318            System.out.println("                   学生姓名:"+SI[j].getname());
319            System.out.println("              1、高等数学成绩 :"+SI[j].getmathematicsscore());
320            System.out.println("              2、大学英语成绩:"+SI[j].getenglishscore());
321            System.out.println("              3、计算机网络成绩:"+SI[j].getnetworkscore());
322            System.out.println("              4、数据库成绩:"+SI[j].getdatabasescore());
323            System.out.println("              5、软件工程成绩:"+SI[j].getsoftwarescore());
324             concullate();
325            System.out.println("                是否返回主界面(Y/N)");
326            System.out.println("********************************************************");
327            pandun3();
328        }
329        public void concullate()           //判断学生绩点是否满足毕业要求
330        {   double sum=0;
331            sum+=scorepoint(SI[j].getmathematicsscore())*5.0;
332            sum+=scorepoint(SI[j].getenglishscore())*3.0;
333            sum+=scorepoint(SI[j].getnetworkscore())*4.0;
334            sum+=scorepoint(SI[j].getdatabasescore())*3.0;
335            sum+=scorepoint(SI[j].getsoftwarescore())*4.0;
336            sum=sum/19;
337            String result=String.format("%.2f",sum);
338            System.out.println("           你的平均学分绩点为:"+result);
339            if(sum>=2.0)
340                System.out.println("     提示信息:你的学分绩点已达到毕业要求!");
341            else
342                System.out.println("     提示信息:你的学分绩点不满足毕业要求!");
343        }
344        public double scorepoint(double sdc)          //返回学生成绩对应的绩点
345        {  
346            double index0=0;
347         if(sdc<60)
348         {
349             index0=0;
350         }
351         else if(sdc>=60&&sdc<=63.9)
352         {
353             index0=1.0;
354         }
355         else if(sdc>=64&&sdc<=65.9)
356         {
357             index0=1.5;
358         }
359         else if(sdc>=66&&sdc<=67.9)
360         {
361             index0=1.7;
362         }
363         else if(sdc>=68&&sdc<=71.9)
364         {
365             index0=2.0;
366         }
367         else if(sdc>=72&&sdc<=74.9)
368         {
369             index0=2.3;
370         }
371         else if(sdc>=75&&sdc<=77.9)
372         {
373             index0=2.7;
374         }
375         else if(sdc>=78&&sdc<=81.9)
376         {
377             index0=3.0;
378         }
379         else if(sdc>=82&&sdc<=84.9)
380         {
381             index0=3.3;
382         }
383         else if(sdc>=85&&sdc<=88.9)
384         {
385             index0=3.7;
386         }
387         else
388             index0=4.0;
389         return index0;
390        }
391        public void pandun3()            //输入Y或N后进行相应的操作
392     {
393         String temp9=te.next();
394         if(temp9.equals("Y"))
395         {
396             meau();
397         }
398         else;
399     }
400 }

?

主函数

 1 package adc;
 2 import java.util.*;
 3 public class Text {
 4 
 5     public static void main(String[] args) 
 6     {
 7         Scanner input=new Scanner(System.in);
 8         ScoreMangerment SM=new ScoreMangerment();
 9         SM.meau();                  //显示系统主界面
10         while(true)
11         {
12             int a=input.nextInt();
13             if(a==1)
14             {
15                 SM.scorerecord();        //调用成绩录入函数
16                 
17             }
18             else if(a==2)
19             {
20                 SM.modifyscore();    //调用成绩修改函数
21             }
22             else if(a==3)
23             {
24                 SM.calulatescorepoint();     //调用计算学生绩点函数
25             }
26             else if(a==4)             //退出系统
27             {
28                 System.out.println("********************************************************");
29                 System.out.println("             t石家庄铁道大学软件工程系学籍管理2019版");
30                 System.out.println("             t制作人:王兵兵");
31                 System.out.println("********************************************************");
32                 break;
33             }
34             else      //防止输入的选项不存在
35             {
36                 System.out.println("该选项不存在!");
37                 SM.meau();
38             }
39         }
40         input.close(); 
41     }
42     
43 }

?

心得体会:在写复杂且代码量庞大的程序时,一定要保证自己的逻辑思维清楚,一旦混乱,就会条理不清,调试寻找代码错误就会花费很长时间,所以逻辑思维很重要。

再者自己要保持良好的心态,一定要把题读懂读透,不要看一遍题后就立即开始做,先构造下自己的思路和框架。

最后就是基本功不扎实:对键盘不熟悉,敲代码的速度过慢以及准确率低,日后要多加练习。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读