-->
当前位置:首页 > 题库

PROGRAMMING:CPP score statistics of students

Luz5年前 (2021-05-10)题库476
After "student CPP score calculation", modify the person and student classes, and add two parameterless constructors respectively.
Still based on the person class, create a derived class teacher, and add the following member data:
int ID;// Teacher job number
Student stu[100];// Student array
int count;// Number of students, up to 100
float cpp_ average;// Average CPP score of class
Add the following member functions:
Parameterized constructor of teacher class
Void add (Student & stu1) / / add a student record to the student array
void average();// Calculate the average CPP of the current class_ average
Void print() / / output the information of the students in the current class
//Among them, the CPP in the student records_ Score and CPP_ The grade output retains one decimal place
//CPP of current class_ The average output retains one decimal place;
//The output format is as follows:
//First line: teacher job number teacher name class student number CPP_ average
//From the second line to the count + 1 line, each line outputs a student's information, and the format of each line is
//Student ID student name CPP_ grade
//cpp_ Grade keeps one decimal place
Generate the above class and write the main function, establish a teacher object according to the input basic information of teachers, establish a student object according to the input basic information of each student, calculate the students' CPP score and add it into the student array, calculate the average CPP score of the class by the teacher object, and output all the information of the class students.
Input format: the test input contains a test case. In the first line of the test case, enter the basic information of the teacher (teacher name, teacher job number, age), the second line begins to enter the information of the students in the class, and each student's basic information accounts for one line (student name, student number, age, CPP score, CPP attendance), up to 100 lines. When reading 0, the input ends.
Input example:
Mike 901 30
Bob 10001 18 75.9 4
Anna 10003 19 87.0 5
0
Output example:
901 Michale 2 82.3
10001 Bob 76.3
10003 Anna 88.3






answer:If there is no answer, please comment