学生成绩管理系统

  1 package 学生成绩管理系统;
  2 import java.util.Scanner;//导入java输入流 
  3 import java.lang.*; 
  4 import java.io.*; 
  5 
  6 class ScoreInformation {
  7     private static ScoreInformation[] s=new ScoreInformation[5];//定义静态学生对象数组
  8     private static int[] sum=new int[6] ;                        //辅助界面打印
  9     private static double[] m=new double[6] ;
 10     private static String num1;
 11     private static int q=0;
 12     private static int o=0;
 13     private static int p=0;
 14     private static double n;
 15     private static double[] l=new double[6] ;
 16     private String stunumber;//学生成绩基本数据
 17     private String name;
 18     private double mathematicsscore;
 19     private double englishiscore;
 20     private double networkscore;
 21     private double databasescore;
 22     private double softwarescore;
 23     public void setstu(String stunumber){//基本数据的设置
 24         this.stunumber=stunumber;
 25     }
 26     public void setname(String name){
 27         this.name=name;
 28     }
 29     public void  setmathematicsscore(double mathematicsscore){
 30         this.mathematicsscore=mathematicsscore;
 31     }
 32     public void  setenglishiscore(double englishiscore){
 33         this.englishiscore=englishiscore;
 34     }
 35     public void  setnetworkscore(double networkscore){
 36         this.networkscore=networkscore;
 37     }
 38     public void  setdatabasescore(double databasescore){
 39         this.databasescore=databasescore;
 40     }
 41     public void  setsoftwarescore(double softwarescore){
 42         this.softwarescore=softwarescore;
 43     }
 44     public String getstu(){//基本数据的获取
 45         return stunumber;
 46     }
 47     public String  getname(){
 48         return name;
 49     }
 50     public double  getmathematicsscore(){
 51         return mathematicsscore;
 52     }
 53     public double getenglishiscore(){
 54         return englishiscore;
 55     }
 56     public double getnetworkscore(){
 57         return networkscore;
 58     }
 59     public double getdatabasescore(){
 60         return databasescore;
 61     }
 62     public double getsoftwarescore(){
 63         return softwarescore;
 64     }
 65     public void print1(){//主界面打印
 66         System.out.println("***********************************************************");
 67         System.out.println("                                                            ");
 68         System.out.println("             石家庄铁道大学软件工程系                   ");
 69         System.out.println("             学生学籍管理系统 2019 版                   ");
 70         System.out.println("                                                            ");
 71         System.out.println("***********************************************************");
 72         System.out.println("                                                            ");
 73         System.out.println("               1、 学生考试成绩录入 ");
 74         System.out.println("               2、 学生考试成绩修改");
 75         System.out.println("                   3、 计算学生成绩绩点");
 76         System.out.println("                 4、退出学籍管理系统");
 77         System.out.println("                                                            ");
 78         System.out.println("***********************************************************");
 79     }
 80     public void print2(){//成绩录用界面打印
 81         System.out.println("***********************************************************");
 82         System.out.println("                                                            ");
 83         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
 84         System.out.println("                学生考试成绩录入    ");
 85         System.out.println("                                                            ");
 86         System.out.println("***********************************************************");
 87         System.out.println("                                                            ");
 88         System.out.println("                请输入学生学号:");
 89         System.out.println("                                                            ");
 90         System.out.println("***********************************************************");
 91         System.out.println("请输入学生学号(8位):");
 92     }
 93     public void print3(){//成绩修改界面打印
 94         System.out.println("***********************************************************");
 95         System.out.println("                                                            ");
 96         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
 97         System.out.println("                学生考试成绩修改界面    ");
 98         System.out.println("                                                            ");
 99         System.out.println("***********************************************************");
100         System.out.println("                                                            ");
101         System.out.println("                请输入学生学号:");
102         System.out.println("                                                            ");
103         System.out.println("***********************************************************");
104         System.out.println("请输入学生学号(8位):");
105     }
106     public void print4(){//成绩修改功能实现界面打印
107         System.out.println("***********************************************************");
108         System.out.println("                                                            ");
109         System.out.println("    石家庄铁道大学软件工程系学生学籍管理系统 2019 版           ");
110         System.out.println("                  学生考试成绩录入界面                       ");
111         System.out.println("                                                            ");
112         System.out.println("***********************************************************");
113         System.out.println("                                                            ");
114         System.out.println("                   学生学号:"+num1+"             ");
115         System.out.println("                   学生姓名:"+s[q].name+"             ");
116         if(p==1)
117         {
118             System.out.println("                   请输入修改后高等数学成绩:                       ");
119         }
120         else if(p==2)
121         {
122             System.out.println("                   请输入修改后大学英语成绩:                       ");
123         }
124         else if(p==3)
125         {
126             System.out.println("                   请输入修改后计算机网络成绩:                       ");
127         }
128         else if(p==4)
129         {
130             System.out.println("                   请输入修改后数据库成绩:                ");
131         }
132         else if(p==5)
133         {
134             System.out.println("                   请输入修改后软件工程成绩:                       ");
135         }
136         System.out.println("                                                            ");
137         System.out.println("***********************************************************");
138     }
139     public void print5(){//成绩显示界面打印(显示该学生所有信息)
140         System.out.println("***********************************************************");
141         System.out.println("                                                            ");
142         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
143         System.out.println("                学生考试成绩录入    ");
144         System.out.println("                                                            ");
145         System.out.println("***********************************************************");
146         System.out.println("                                                            ");
147         System.out.println("                   学生学号:"+num1+"             ");
148         System.out.println("                   学生姓名:"+s[q].name+"             ");
149         System.out.println("               1、 高等数学成绩: "+s[q].mathematicsscore+"             ");
150         System.out.println("               2、 大学英语成绩:"+s[q].englishiscore+"             ");
151         System.out.println("                   3、 计算机网络成绩:"+s[q].networkscore+"             ");
152         System.out.println("                 4、数据库成绩:"+s[q].databasescore+"             ");
153         System.out.println("                 5、软件工程成绩:"+s[q].softwarescore+"             ");
154         if(o==1)
155         {
156             System.out.println("                   该学生成绩已录入完毕,是否提交(Y/N)               ");
157             o=0;
158         }
159         System.out.println("                                                            ");
160         System.out.println("***********************************************************");
161     }
162     public void print6(){//退出界面打印
163         System.out.println("***********************************************************");
164         System.out.println("                                                            ");
165         System.out.println("    石家庄铁道大学软件工程系学生学籍管理系统 2019 版           ");
166         System.out.println("            制作人:陈琪           ");
167         System.out.println("                                                            ");
168         System.out.println("***********************************************************");
169     }
170     public void print7(){//成绩录用副界面打印
171         System.out.println("***********************************************************");
172         System.out.println("                                                            ");
173         System.out.println("    石家庄铁道大学软件工程系学生学籍管理系统 2019 版           ");
174         System.out.println("                  学生考试成绩录入界面                       ");
175         System.out.println("                                                            ");
176         System.out.println("***********************************************************");
177         System.out.println("                                                            ");
178         System.out.println("                   学生学号:"+num1+"             ");
179         System.out.println("                   学生姓名:"+s[q].name+"             ");
180         if(sum[0]==1)
181         {
182             System.out.println("                   请输入高等数学成绩:                       ");
183             sum[0]=0;
184         }
185         else if(sum[1]==1)
186         {
187             System.out.println("                   高等数学成绩:"+m[0]+"             ");
188             System.out.println("                   请输入大学英语成绩:                       ");
189             sum[1]=0;
190         }
191         else if(sum[2]==1)
192         {
193             System.out.println("                   高等数学成绩:"+m[0]+"             ");
194             System.out.println("                   大学英语成绩:"+m[1]+"              ");
195             System.out.println("                   请输入计算机网络成绩:                       ");
196             sum[2]=0;
197         }
198         else if(sum[3]==1)
199         {
200             System.out.println("                   高等数学成绩:"+m[0]+"             ");
201             System.out.println("                               大学英语成绩:"+m[1]+"          ");
202             System.out.println("                   计算机网络成绩:"+m[2]+"            ");
203             System.out.println("                   请输入数据库成绩:                ");
204             sum[3]=0;
205         }
206         else if(sum[4]==1)
207         {
208             System.out.println("                   高等数学成绩:"+m[0]+"             ");
209             System.out.println("                               大学英语成绩:"+m[1]+"          ");
210             System.out.println("                   计算机网络成绩:"+m[2]+"            ");
211             System.out.println("                   数据库成绩:"+m[3]+"                ");
212             System.out.println("                   请输入软件工程成绩:                       ");
213             sum[4]=0;
214         }
215         else if(sum[5]==1)
216         {
217             System.out.println("                   高等数学成绩:"+m[0]+"             ");
218             System.out.println("                               大学英语成绩:"+m[1]+"          ");
219             System.out.println("                   计算机网络成绩:"+m[2]+"            ");
220             System.out.println("                   数据库成绩:"+m[3]+"                ");
221             System.out.println("                   软件工程成绩:"+m[4]+"                   ");
222             System.out.println("                   该学生成绩已录入完毕,是否提交(Y/N)               ");
223             sum[5]=0;
224         }
225         System.out.println("                                                            ");
226         System.out.println("***********************************************************");
227         
228     }
229     public void print8(){//成绩显示界面打印(输入数据时的界面)
230         System.out.println("***********************************************************");
231         System.out.println("                                                            ");
232         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
233         System.out.println("                学生考试成绩录入    ");
234         System.out.println("                                                            ");
235         System.out.println("***********************************************************");
236         System.out.println("                                                            ");
237         System.out.println("                   学生学号:"+num1+"             ");
238         System.out.println("                   学生姓名:"+s[q].name+"             ");
239         if(p==1){
240         System.out.println("               1、 高等数学成绩: "+n+"             ");
241         System.out.println("               2、 大学英语成绩:"+s[q].englishiscore+"             ");
242         System.out.println("                   3、 计算机网络成绩:"+s[q].networkscore+"             ");
243         System.out.println("                 4、数据库成绩:"+s[q].databasescore+"             ");
244         System.out.println("                 5、软件工程成绩:"+s[q].softwarescore+"             ");
245         }
246         if(p==2){
247             System.out.println("               1、 高等数学成绩: "+s[q].mathematicsscore+"             ");
248             System.out.println("               2、 大学英语成绩:"+n+"             ");
249             System.out.println("                   3、 计算机网络成绩:"+s[q].networkscore+"             ");
250             System.out.println("                 4、数据库成绩:"+s[q].databasescore+"             ");
251             System.out.println("                 5、软件工程成绩:"+s[q].softwarescore+"             ");
252             }
253         if(p==3){
254             System.out.println("               1、 高等数学成绩: "+s[q].mathematicsscore+"             ");
255             System.out.println("               2、 大学英语成绩:"+s[q].englishiscore+"             ");
256             System.out.println("                   3、 计算机网络成绩:"+n+"             ");
257             System.out.println("                 4、数据库成绩:"+s[q].databasescore+"             ");
258             System.out.println("                 5、软件工程成绩:"+s[q].softwarescore+"             ");
259             }
260         if(p==4){
261             System.out.println("               1、 高等数学成绩: "+s[q].mathematicsscore+"             ");
262             System.out.println("               2、 大学英语成绩:"+s[q].englishiscore+"             ");
263             System.out.println("                   3、 计算机网络成绩:"+s[q].networkscore+"             ");
264             System.out.println("                 4、数据库成绩:"+n+"             ");
265             System.out.println("                 5、软件工程成绩:"+s[q].softwarescore+"             ");
266             }
267         
268         if(p==5){
269             System.out.println("               1、 高等数学成绩: "+s[q].mathematicsscore+"             ");
270             System.out.println("               2、 大学英语成绩:"+s[q].englishiscore+"             ");
271             System.out.println("                   3、 计算机网络成绩:"+s[q].networkscore+"             ");
272             System.out.println("                 4、数据库成绩:"+s[q].databasescore+"             ");
273             System.out.println("                 5、软件工程成绩:"+n+"             ");
274             }
275         System.out.println("                                                            ");
276         System.out.println("***********************************************************");
277     }
278     public void print10(){//成绩绩点计算界面打印
279         System.out.println("***********************************************************");
280         System.out.println("                                                            ");
281         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
282         System.out.println("                学生考试成绩绩点计算界面           ");
283         System.out.println("                                                            ");
284         System.out.println("***********************************************************");
285         System.out.println("                                                            ");
286         System.out.println("                请输入学生学号:");
287         System.out.println("                                                            ");
288         System.out.println("***********************************************************");
289         System.out.println("请输入学生学号(8位):");
290     }
291     public void print9(){//成绩绩点
292         System.out.println("***********************************************************");
293         System.out.println("                                                            ");
294         System.out.println("          石家庄铁道大学软件工程系学生学籍管理系统 2019 版");
295         System.out.println("                学生考试成绩绩点计算界面    ");
296         System.out.println("                                                            ");
297         System.out.println("***********************************************************");
298         System.out.println("                                                            ");
299         System.out.println("                   学生学号:"+num1+"             ");
300         System.out.println("                   学生姓名:"+s[q].name+"             ");
301         System.out.println("               1、 高等数学成绩绩点: "+l[0]+"             ");
302         System.out.println("               2、 大学英语成绩绩点:"+l[1]+"             ");
303         System.out.println("                   3、 计算机网络成绩绩点:"+l[2]+"             ");
304         System.out.println("                 4、数据库成绩绩点:"+l[3]+"             ");
305         System.out.println("                 5、软件工程成绩绩点:"+l[4]+"             ");
306         System.out.println("                    你的平均学分绩点为:"+l[5]+"             ");
307         if(l[5]>=2)
308         {
309             System.out.println("         提示信息:你的学分绩点已达到毕业要求!      ");
310         }
311         else
312         {
313             System.out.println("         提示信息:你的学分绩点不满足毕业要求!      ");
314         }
315         System.out.println("                是否返回系统主界面:(Y/N)               ");
316         System.out.println("                                                            ");
317         System.out.println("***********************************************************");
318         for(int i=0;i<6;i++)
319         {
320             l[i]=0;
321         }
322     }
323     public void menu(){//主界面功能实现
324         Scanner in=new Scanner(System.in);            //实例化输入流对象
325         int a;
326         print1();                                    //菜单界面显示
327         System.out.print("请输入选择(1~4):");
328         a=in.nextInt();                                //用户输入的数
329         while(a<1||a>4)                                //检查非法输入
330         {
331             System.out.print("输入超出范围!请重新输入!\n");
332             print1();
333             a=in.nextInt();
334         }
335         switch(a)                                    //根据用户输入的数选择功能
336         {
337             case 1:this.add();break;
338             case 2:this.modif();break;
339             case 3:this.count();break;
340             case 4:print6();System.exit(0);break;
341         }
342     }
343     
344     public void add(){//成绩录用功能实现
345         int i,t=0;
346         String str;
347         char ch;
348         print3();                                    //录用界面显示
349             Scanner in=new Scanner(System.in);        
350             num1=in.next();                            //用户输入的学号
351             for(i=0;i<5;i++)
352             {
353                 if(num1.equals(s[i].getstu()))        //输入的学号对应的学生
354                 {
355                     t=1;
356                     q=i;
357                     sum[0]=1;                        //辅助界面一个一个的出现
358                     print7();                        //按照要求:输入一个学科成绩完成后提示输入下一个成绩
359                     m[0]=in.nextInt();
360                     sum[1]=1;
361                     print7();
362                     m[1]=in.nextInt();
363                     sum[2]=1;
364                     print7();
365                     m[2]=in.nextInt();
366                     sum[3]=1;
367                     print7();
368                     m[3]=in.nextInt();
369                     sum[4]=1;
370                     print7();
371                     m[4]=in.nextInt();
372                     sum[5]=1;
373                     print7();
374                     System.out.println("请输入选择(Y/N):");//实现若输入y录入的信息保存,输入n则不保存重新录入
375                     Scanner    In =new Scanner(System.in);
376                     str=In.next();
377                     ch=str.charAt(0);
378                     while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n') 
379                       { 
380                         System.out.print("输入有误,请重新输入:"); 
381                         str=In.next(); 
382                         ch=str.charAt(0);
383                       } 
384                       if(ch=='Y'||ch=='y')                 //若输入y录入的信息保存
385                       { 
386                           s[i].setmathematicsscore(m[0]);
387                           s[i].setenglishiscore(m[1]);
388                           s[i].setnetworkscore(m[2]);
389                           s[i].setdatabasescore(m[3]);
390                           s[i].setsoftwarescore(m[4]);
391                           this.menu();
392                       } 
393                       if(ch=='N'||ch=='n')                 //若输入n则不保存重新录入
394                       { 
395                           System.out.print("此次无效\n");
396                           this.add();
397                       } 
398                 }
399             }
400             if(t==0)
401             {
402                 System.out.print("该学号不存在\n");
403                 this.add();
404             }
405     }
406     public double com(double a){//辅助计算绩点(将成绩转化为对应的绩点)
407         double d=0;
408         if(a>=90)
409         {
410             d=4.0;
411         }
412         else if(a<60)
413         {
414             d=0;
415         }
416         else if(a<=89.9&&a>=85)
417         {
418             d=3.7;
419         }
420         else if(a<=84.9&&a>=82)
421         {
422             d=3.3;
423         }
424         else if(a<=77.9&&a>=75)
425         {
426             d=2.7;
427         }
428         else if(a<=74.9&&a>=72)
429         {
430             d=2.3;
431         }
432         else if(a<=71.9&&a>=68)
433         {
434             d=2.0;
435         }
436         else if(a<=67.9&&a>=66)
437         {
438             d=1.7;
439         }
440         else if(a<=65.9&&a>=64)
441         {
442             d=1.5;
443         }
444         else if(a<=63.9&&a>=60)
445         {
446             d=1.0;
447         }
448         
449         return d;
450     }
451     public void count(){//成绩计算绩点功能实现
452         int i;
453         String str;
454         char ch;
455         print10();
456         Scanner in=new Scanner(System.in);
457         num1=in.next();                                    //用户输入学号
458         for(i=0;i<5;i++)
459         {
460             if(num1.equals(s[i].getstu()))
461             {
462                 q=i;
463                 l[0]=com(s[i].mathematicsscore);        //计算每门学科成绩对应绩点
464                 l[1]=com(s[i].englishiscore);
465                 l[2]=com(s[i].networkscore);
466                 l[3]=com(s[i].databasescore);
467                 l[4]=com(s[i].softwarescore);
468                 l[5]=(l[0]*4+l[1]*3+l[2]*4+l[3]*3+l[4]*2)/16;    //计算该学生平均学分绩点
469                 print9();
470             }
471         }
472         Scanner    In =new Scanner(System.in);
473         System.out.println("请输入选择(Y/N):");
474         str=In.next();
475         ch=str.charAt(0);
476         while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n') 
477           { 
478             System.out.print("输入有误,请重新输入:"); 
479             str=In.next(); 
480             ch=str.charAt(0);
481           } 
482           if(ch=='Y'||ch=='y') 
483           { 
484               this.menu();
485           } 
486           if(ch=='N'||ch=='n') 
487           { 
488           }
489         
490     }
491     public void modif(){//成绩修改功能实现
492         int i,t=0;
493         String str;
494         char ch;
495         print3();
496         Scanner in=new Scanner(System.in);
497         num1=in.next();
498         for(i=0;i<5;i++)
499         {
500             if(num1.equals(s[i].getstu()))
501             {
502                 t=1;
503                 q=i;
504             }
505         }
506         if(t==0)
507         {
508             System.out.print("该学号不存在\n");
509             this.add();
510         }
511         else
512         {
513             print5();
514             System.out.println("请输入选择修改科目成绩的编号(1~5):");
515             Scanner In=new Scanner(System.in);
516             p=In.nextInt();
517             print4();
518             Scanner In1=new Scanner(System.in);
519             n=In1.nextInt();
520             print8();
521             System.out.println("请输入选择(Y/N):");
522             Scanner    In2 =new Scanner(System.in);
523             str=In2.next();
524             ch=str.charAt(0);
525             while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n') 
526             { 
527                 System.out.print("输入有误,请重新输入:"); 
528                 str=In.next(); 
529                 ch=str.charAt(0);
530             } 
531             if(ch=='Y'||ch=='y') 
532             { 
533                   if(p==1)
534                     {
535                         s[q].setmathematicsscore(n);
536                     }
537                     else if(p==2)
538                     {
539                         s[q].setenglishiscore(n);
540                     }
541                     else if(p==3)
542                     {
543                         s[q].setnetworkscore(n);
544                     }
545                     else if(p==4)
546                     {
547                         s[q].setdatabasescore(n);
548                     }
549                     else if(p==5)
550                     {
551                         s[q].setsoftwarescore(n);
552                     }
553                       this.menu();
554                       o=1;
555                       print5();
556             } 
557             if(ch=='N'||ch=='n') 
558             { 
559                   System.out.print("此次无效\n");
560                   this.modif();
561             } 
562             p=0;
563         }
564     }
565     
566     public static void main(String[] args)
567       {   
568         ScoreInformation stu=new ScoreInformation(); 
569         for(int i=0;i<5;i++)//分配储存空间
570         {
571             s[i]=new ScoreInformation();
572         }
573         for(int i=0;i<5;i++)
574         {
575             sum[i]=0;
576         }
577         s[0].setstu("20183528");//五个学生信息的初始化
578         s[1].setstu("20183527");
579         s[2].setstu("20183526");
580         s[3].setstu("20183525");
581         s[4].setstu("20183524");
582         s[0].setname("陈琪");
583         s[1].setname("薛普");
584         s[2].setname("刘某");
585         s[3].setname("李某");
586         s[4].setname("王某");
587         stu.menu();//调用菜单
588       } 
589     
590 }

 

 

 

 

 

 

 

 

 

 

 

 

 

解题思路:

1、 首先创建学生对象数组,定义学生的基本信息(姓名、学号、高数成绩、大学英语成绩、计算机网路成绩、数据库成绩、软件工程成绩)。

2、基本数据的设置的功能函数定义,基本数据获取功能函数定义。

3、因为系统中界面较多,所以将功能和界面打印分开。

4、设计菜单,菜单用switch语句实现四个功能的选择。

5、分别设计四个功能函数的框架(成绩录入、成绩修改、成绩绩点查询、退出)。

6、主方法中为五个学生对象分配空间,并初始化五个学生的姓名和学号,调用菜单。

7、具体完善各个功能函数。

原文地址:https://www.cnblogs.com/chenaiiu/p/11508944.html