4. (20 scores)

4. (20 scores)#

Programming for under graduate students graduation audits: read basic information, according to the requirements of graduation audit, output the information into studentGradutate.data file.

Among them, under graduate students are required to complete at least 150 credits, and graduate students are required to complete at least 36 credits, and pass both teaching practice and scientific research assessement.

The contents of the question include:

UStudent
1string strId;     // Student number
2string strNames;  // Student name
3double dCredits;  // Credits completed
4bool bResult;     // Can graduate or not
GStudent
1string strId;     // Student number
2string strNames;  // Student name
3double dCredits;  // Credits completed
4bool bResult;     // Can graduate or not
5bool bTeaching;   // Pass teaching practice or not
6bool bResearch;   // Pass scientific research assessement or not

Complete the following classes called Student, UStudent, GStudent, and the main function, so that the program can create a studentGraduate.data file as following correctly:

 1#include <fstream>
 2#include <string>
 3#include <vector>
 4
 5class Student {
 6 public:
 7  // ...
 8
 9 private:
10  std::string strId;
11  std::string strName;
12};
13
14class UStudent : public Student {
15 public:
16  // ...
17
18 private:
19  double dCredits;
20  bool bResult;
21};
22
23class GStudent : public UStudent {
24 public:
25  // ...
26
27 private:
28  double bTeaching;
29  bool bResearch;
30};
31
32int main() {
33  std::vector<Student*> s(4);
34  s[0] = new UStudent(1001, "Donald", 156, 1);
35  s[1] = new UStudent(1002, "Vivion", 142, 0);
36  s[2] = new GStudent(2003, "Chris", 36, 1, 1, 1);
37  s[3] = new GStudent(2004, "Cindy", 38, 1, 1, 1);
38
39  // output the information of students in to "studentGraduate.data" file
40  //according to the bResult data
41
42  { /* fill the blanks here */ }
43
44  for (int i = 0; i < s.size(); i++) {
45    delete s[i];
46  }
47}
studentGraduate.data#
11001 Donald 156 1
22003 Chris 36 1 1 1
32004 Cindy 38 1 1 1