首页 > 代码库 > 学生成绩管理系统

学生成绩管理系统

  1 //学生成绩管理系统 V1.0
  2 //student.cpp
  3 //Made By SUT_Hui 
  4 //2012-3-12
  5 //wangchunhui@wangchunhui.cn 
  6 
  7 #include <iostream>
  8 #include <fstream>
  9 #include <string>
 10 #include <iomanip> 
 11 
 12 //#define course_mount 5
 13 
 14 using namespace std;
 15 
 16 /*
 17 //----------------------------------------------------------course 类
 18 class course
 19 {
 20     private:
 21     state int Course_number_count;
 22     string Course_name;
 23     string Course_teacher;
 24     public:
 25     course();
 26     void add_course();
 27     ~course();
 28 };
 29 */
 30 int n=0;//TEST = 4,Normal = 0;
 31 int  m=0, i=1, j=0;
 32 double class_course_everage[4]={0};
 33 
 34 //----------------------------------------------------------student 类
 35 
 36 class student
 37 {
 38     private:
 39 //    static int count; 
 40     string Student_name;
 41     string Student_No;
 42     char Student_sex;
 43     double Student_score_everage;
 44     double Maths;
 45     double Chinese;
 46     double English;
 47     double CPP;
 48     public:
 49     student();
 50     void init_student();
 51 //    void score_everage();
 52     void init_score();
 53     string getStudent_No();
 54     string getStudent_name();
 55     char getStudent_sex();
 56     double getscore_sum();
 57     double getStudent_score_everage();
 58     double getStudent_score_Maths();
 59     double getStudent_score_Chinese();
 60     double getStudent_score_English();
 61     double getStudent_score_CPP();
 62     ~student()
 63     {
 64         cout<<"Waitng..."<<endl;
 65     }
 66 }students[40];
 67 
 68 //-----------------------------------------------------------函数声明
 69 
 70 void welcome();
 71 int Main_student();
 72 int Main_student_input_1();
 73 int Main_student_input_1();
 74 int Main_student_list_2();
 75 int Main_student_correct_3();
 76 int Main_student_coursename_4();
 77 int Main_student_scoreinput_5();
 78 int Main_student_courseeverage_6();
 79 int Main_student_class_courseeverage_7();
 80 int Main_student_ALL_8();
 81 int Main_copyright_9();
 82 
 83 //-----------------------------------------------------------main 函数 
 84 
 85 int main()
 86 {
 87     welcome();
 88     return Main_student();
 89 }
 90 
 91 //-----------------------------------------------------------class student 类函数定义
 92 
 93 student::student()
 94 {
 95     Student_name = " ";
 96     Student_No = " ";
 97     Student_sex = M;
 98     Maths = 0.0;
 99     Chinese = 0.0;
100     English = 0.0;
101     CPP = 0.0;
102 }
103 
104 //__________________________TEST
105 /*
106 student::student()
107 {
108     Student_name = "未命名";
109     Student_No = "#########";
110     Student_sex = ‘M‘;
111     Maths = 50.50;
112     Chinese = 50.50;
113     English = 50.50;
114     CPP = 50.50;
115 }
116 //___________________________TEXT 
117 */
118 
119 void student::init_student()
120 {
121     int len_name, len_No;
122     cout<<"\n              请输入第"<<i+1<<"个学生基本信息"<<endl;
123     cout<<"              姓名:";cin>>Student_name;getchar();
124     cout<<"              学号:";cin>>Student_No;getchar();
125     cout<<"              性别:(F/M)";cin>>Student_sex;getchar();
126     len_name = Student_name.length();
127     len_No = Student_No.length();
128     if(len_name < 6)
129     {
130         for(;len_name<6;len_name++)
131         {
132             Student_name += " ";
133         }
134     }
135     if(len_No < 9)
136     {
137         for(; len_No < 9; len_No++)
138         {
139             Student_No+=" ";
140         }
141     }
142 }
143 
144 void student::init_score()
145 {
146     cout<<"                "<<"学生-"<<students[i].getStudent_name()<<"成绩录入:"<<endl;
147     cout<<"                "<<"数学:"; cin>>Maths;getchar();
148     cout<<"                "<<"语文:"; cin>>Chinese;getchar();
149     cout<<"                "<<"英语:"; cin>>English;getchar();
150     cout<<"                "<<"C++ :"; cin>>CPP;getchar();
151 }
152 /*
153 void student::score_everage()
154 {
155     Student_score_everage=(Maths+Chinese+English+CPP)/4;
156 }
157 */
158 string student::getStudent_No()
159 {
160     return Student_No;
161 }
162 
163 string student::getStudent_name()
164 {
165     return Student_name;
166 }
167 
168 char student::getStudent_sex()
169 {
170     return Student_sex;
171 }
172 
173 double student::getscore_sum()
174 {
175     return (Maths+Chinese+English+CPP);
176 }
177 
178 double student::getStudent_score_everage()
179 {
180     Student_score_everage=(Maths+Chinese+English+CPP)/4;
181     return Student_score_everage;
182 }
183 
184 double student::getStudent_score_Maths()
185 {
186     return Maths;
187 }
188 
189 double student::getStudent_score_Chinese()
190 {
191     return Chinese;
192 }
193 
194 double student::getStudent_score_English()
195 {
196     return English;
197 }
198 
199 double student::getStudent_score_CPP() 
200 {
201     return CPP;
202 }
203 
204 //-----------------------------------------------------------函数定义 
205 
206 void welcome()
207 {
208     cout<<"\n\n\n\n\n\n";
209     cout<<"             ========================================"<<endl;
210     cout<<"             =                                      ="<<endl;
211     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
212     cout<<"             =                                      ="<<endl;
213     cout<<"             ========================================"<<endl;
214     cout<<"             =             MADE BY  SUT_HUi         ="<<endl;
215     cout<<"             =           START AT    2012/3/12      ="<<endl;
216     cout<<"             ========================================"<<endl;
217     cout<<"\n\n             按回车进入...";
218     getchar();
219     system("cls");
220 }
221 
222 int Main_student()
223 {
224     int flag = 0;
225     while(!flag)
226     {
227         char choose;
228         cout<<"\n\n\n\n";
229         cout<<"             ========================================"<<endl;
230         cout<<"             =                                      ="<<endl;
231         cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
232         cout<<"             =               管理界面               ="<<endl;
233         cout<<"             ========================================"<<endl;
234         cout<<"             =         1.学生基本信息录入           ="<<endl;
235         cout<<"             =         2.学生基本信息列表           ="<<endl;
236         cout<<"             =         3.学生基本信息修改           ="<<endl;
237         cout<<"             =         4.科目名称修改               ="<<endl;
238         cout<<"             =         5.分数录入                   ="<<endl;
239         cout<<"             =         6.个人成绩状况               ="<<endl;
240         cout<<"             =         7.班级成绩状况               ="<<endl;
241         cout<<"             =         8.总表                       ="<<endl;
242         cout<<"             =         9.版权信息                   ="<<endl;
243         cout<<"             =         0.退出                       ="<<endl;
244         cout<<"             ========================================"<<endl;
245         cout<<"             请选择:"; 
246         do{
247             cin>>choose;getchar();
248             switch(choose)
249             {
250                 case 1:system("cls"); flag = Main_student_input_1();system("cls"); break;
251                 case 2:system("cls"); flag = Main_student_list_2(); break;
252                 case 3:system("cls"); flag = Main_student_correct_3(); break;
253                 case 4:system("cls"); flag = Main_student_coursename_4(); break;
254                 case 5:system("cls"); flag = Main_student_scoreinput_5(); break;
255                 case 6:system("cls"); flag = Main_student_courseeverage_6(); break;
256                 case 7:system("cls"); flag = Main_student_class_courseeverage_7(); break;
257                 case 8:system("cls"); flag = Main_student_ALL_8(); break;
258                 case 9:system("cls"); flag = Main_copyright_9(); break;
259                 case 0:return (0);
260                 default:flag++;cout<<"             输入有误请重新输入:";  
261                         if(flag == 10) {cout<<"ERROR!"<<endl<<"正在退出"<<endl;return (1);}
262             }
263         }while(flag);
264         system("cls");
265     }
266 }
267 
268 int Main_student_input_1()
269 {
270     cout<<"\n\n\n\n";
271     cout<<"             ========================================"<<endl;
272     cout<<"             =                                      ="<<endl;
273     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
274     cout<<"             =            学生基本信息录入          ="<<endl;
275     cout<<"             ========================================"<<endl;
276     cout<<"              请输入学生人数(MAX=40):";
277     cin>>n;
278     for(i=0;i<n;i++)
279     {
280         students[i].init_student();
281     }
282     cout<<"\n             ========================================"<<endl;
283     cout<<"              录入完毕,按回车返回主菜单...";getchar();
284     return 0;
285 }
286 
287 int Main_student_list_2()
288 {
289     cout<<"\n\n\n\n";
290     cout<<"             ========================================"<<endl;
291     cout<<"             =                                      ="<<endl;
292     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
293     cout<<"             =            学生基本信息列表          ="<<endl;
294     cout<<"             ========================================"<<endl;
295     cout<<"               序号     学号       姓名       性别   "<<endl;
296     for(i=0;i<n;i++)
297     {
298     cout<<"                "<<setw(2)<<i+1<<"   "<<students[i].getStudent_No()<<"    "<<students[i].getStudent_name()<<"       "<<students[i].getStudent_sex()<<endl;
299     }
300     cout<<"\n             ========================================"<<endl;
301     cout<<"              按回车返回主菜单...";getchar();
302     return 0;
303 }
304 
305 int Main_student_correct_3()
306 {
307     cout<<"\n\n\n\n";
308     cout<<"             ========================================"<<endl;
309     cout<<"             =                                      ="<<endl;
310     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
311     cout<<"             =            学生基本信息修改          ="<<endl;
312     cout<<"             ========================================"<<endl;
313     cout<<"                                                     "<<endl;
314     cout<<"                                                     "<<endl;
315     cout<<"                            未注册组件               "<<endl;
316     cout<<"                                                     "<<endl;
317     cout<<"                                                     "<<endl;
318     cout<<"             ========================================"<<endl;
319     cout<<"               按回车返回主菜单...";getchar(); 
320     return 0;
321 }
322 
323 int Main_student_coursename_4()
324 {
325     cout<<"\n\n\n\n";
326     cout<<"             ========================================"<<endl;
327     cout<<"             =                                      ="<<endl;
328     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
329     cout<<"             =             科目名称修改             ="<<endl;
330     cout<<"             ========================================"<<endl;
331     cout<<"                                                     "<<endl;
332     cout<<"                                                     "<<endl;
333     cout<<"                            未注册组件               "<<endl;
334     cout<<"                                                     "<<endl;
335     cout<<"                                                     "<<endl;
336     cout<<"             ========================================"<<endl;
337     cout<<"               按回车返回主菜单...";getchar();
338     return 0;
339 }
340 
341 int Main_student_scoreinput_5()
342 {
343     cout<<"\n\n\n\n";
344     cout<<"             ========================================"<<endl;
345     cout<<"             =                                      ="<<endl;
346     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
347     cout<<"             =              学生分数录入            ="<<endl;
348     cout<<"             ========================================"<<endl;
349     for(i=0;i<n;i++)
350     {
351         students[i].init_score();
352     }
353     cout<<"\n             ========================================"<<endl;
354     cout<<"              按回车返回主菜单...";getchar();
355     return 0;
356 }
357 
358 int Main_student_courseeverage_6()
359 {
360     cout<<"\n\n\n\n";
361     cout<<"             ========================================"<<endl;
362     cout<<"             =                                      ="<<endl;
363     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
364     cout<<"             =             个人成绩状况             ="<<endl;
365     cout<<"             ========================================"<<endl;
366     cout<<"               序号    学号        姓名      平均分  "<<endl;
367     for(i=0;i<n;i++)
368     {
369         //students[i].score_everage();
370         cout <<setiosflags(ios::fixed);
371     cout<<"                "<<setw(2)<<i+1<<"   "<<students[i].getStudent_No()<<"    "<<students[i].getStudent_name()<<"     "<<setw(6)<<setprecision(2)<<students[i].getStudent_score_everage()<<endl;
372     }
373     cout<<"\n             ========================================"<<endl;
374     cout<<"              按回车返回主菜单...";getchar();
375     return 0;
376 }
377 
378 int Main_student_class_courseeverage_7()
379 {
380     cout<<"\n\n\n\n";
381     cout<<"             ========================================"<<endl;
382     cout<<"             =                                      ="<<endl;
383     cout<<"             =          学生成绩管理系统 V1.0       ="<<endl;
384     cout<<"             =             科目平均分查询           ="<<endl;
385     cout<<"             ========================================"<<endl;
386     cout<<"                       科目        平均分            "<<endl;
387     for(i=0;i<n;i++)
388     {
389         class_course_everage[0]+= students[i].getStudent_score_Maths();
390         class_course_everage[1]+= students[i].getStudent_score_Chinese();
391         class_course_everage[2]+= students[i].getStudent_score_English();
392         class_course_everage[3]+= students[i].getStudent_score_CPP();
393     }
394     cout <<setiosflags(ios::fixed);
395     cout<<"                      数 学:"<<"        "<<setw(6)<<setprecision(2)<<class_course_everage[0]/n<<endl;
396     cout<<"                      语 文:"<<"        "<<setw(6)<<setprecision(2)<<class_course_everage[1]/n<<endl;
397     cout<<"                      英 语:"<<"        "<<setw(6)<<setprecision(2)<<class_course_everage[2]/n<<endl;
398     cout<<"                       C++ :"<<"        "<<setw(6)<<setprecision(2)<<class_course_everage[3]/n<<endl;
399     cout<<"\n             ========================================"<<endl;
400     cout<<"              按回车返回主菜单...";getchar();
401     return 0;
402 }
403 
404 int Main_student_ALL_8()
405 {
406     for(i=0;i<n;i++)
407     {
408         class_course_everage[0]+= students[i].getStudent_score_Maths();
409         class_course_everage[1]+= students[i].getStudent_score_Chinese();
410         class_course_everage[2]+= students[i].getStudent_score_English();
411         class_course_everage[3]+= students[i].getStudent_score_CPP();
412     }
413     cout<<"\n\n\n\n";
414     cout<<"             =========================================================="<<endl;
415     cout<<"             =                                                        ="<<endl;
416     cout<<"             =                   学生成绩管理系统 V1.0                ="<<endl;
417     cout<<"             =                     学生成绩信息总表                   ="<<endl;
418     cout<<"             =========================================================="<<endl;
419     cout<<"              序号   学号     姓名   数学   语文   英语    C++   平均分"<<endl;
420     for(i=0;i<n;i++)
421     {
422     //    students[i].score_everage();
423     cout <<setiosflags(ios::fixed);
424     cout<<"                "<<i+1<<" "<<students[i].getStudent_No()<<"  "<<students[i].getStudent_name()<<setw(7)<<setprecision(2)<<students[i].getStudent_score_Maths()<<setw(7)<<setprecision(2)<<students[i].getStudent_score_Chinese()<<setw(7)<<setprecision(2)<<students[i].getStudent_score_English()<<setw(7)<<setprecision(2)<<students[i].getStudent_score_CPP()<<setw(7)<<setprecision(2)<<students[i].getStudent_score_everage()<<endl;
425     }
426     cout<<"              "<<"==平均分==      ***  "<<setw(7)<<setprecision(2)<<class_course_everage[0]/4<<setw(7)<<setprecision(2)<<class_course_everage[1]/4<<setw(7)<<setprecision(2)<<class_course_everage[2]/4<<setw(7)<<setprecision(2)<<class_course_everage[3]/4<<setw(7)<<setprecision(2)<<(class_course_everage[0]+class_course_everage[1]+class_course_everage[2]+class_course_everage[3])/16; 
427     cout<<"\n             =========================================================="<<endl;
428     cout<<"             按回车返回主菜单...";getchar();
429     return 0;
430 }
431 
432 int Main_copyright_9()
433 {
434     cout<<"\n\n\n\n";
435     cout<<"            =========================================="<<endl;
436     cout<<"            =                                        ="<<endl;
437     cout<<"            =           学生成绩管理系统 V1.0        ="<<endl;
438     cout<<"            =                                        ="<<endl;
439     cout<<"            =========================================="<<endl;
440     cout<<"            =                                        ="<<endl;
441     cout<<"            =             MADE BY SUT_Hui            ="<<endl;
442     cout<<"            =                                        ="<<endl;
443     cout<<"            =All Copyright Reserved 2012-2012 SUT_Hui="<<endl;
444     cout<<"            =    GPL2.0 2011 SUT_Hui Project TEAM    ="<<endl;
445     cout<<"            =========================================="<<endl;
446     cout<<"             按回车返回主菜单...";getchar();
447     return 0;
448 }