- 30 Days of Code
- Day 12: Inheritance
Today, we're delving into Inheritance. Check out the attached tutorial for learning materials and an instructional video.
You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are provided for you in the editor. Observe that Student inherits all the properties of Person.
Complete the Student class by writing the following:
- A Student class constructor, which has parameters:
- A string, .
- A string, .
- An integer, .
- An integer array (or vector) of test scores, .
- A char calculate() method that calculates a Student object's average and returns the grade character representative of their calculated average:
The locked stub code in the editor reads the input and calls the Student class constructor with the necessary arguments. It also calls the calculate method which takes no arguments.
The first line contains , , and , separated by a space. The second line contains the number of test scores. The third line of space-separated integers describes .
Output is handled by the locked stub code. Your output will be correct if your Student class constructor and calculate() method are properly implemented.
Heraldo Memelli 8135627 2 100 80
Name: Memelli, Heraldo ID: 8135627 Grade: O
This student had scores to average: and . The student's average grade is . An average grade of corresponds to the letter grade , so the calculate() method should return the character