 # Day 12: Inheritance | HackerRank Solution

Hello coders, today we are going to solve Day 12: Inheritance HackerRank Solution in C++Java and Python.

## Objective

Today, we’re delving into Inheritance.

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:

• Student class constructor, which has 4 parameters:
1. A string, firstName.
2. A string, lastName.
3. An integer, idNumber.
4. An integer array (or vector) of test scores, scores.
• char calculate() method that calculates a Student object’s average and returns the grade character representative of their calculated average:

## Input Format

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 firstnamelastName, and idNumber, separated by a space. The second line contains the number of test scores. The third line of space-separated integers describes scores.

## Constraints

• 1 <= length of firstName, length of lastName <= 10
• length of idNumber = 7
• 0 <= score <= 100

## Output Format

Output is handled by the locked stub code. Your output will be correct if your Student class constructor and calculate() method are properly implemented.

Sample Input

Sample Output

Explanation

This student had 2 scores to average: 100 and 80. The student’s average grade is (100 + 800) / 2 = 90. An average grade of 90 corresponds to the letter grade O, so the calculate() method should return the character`'O'`.

## Solution – Day 12: Inheritance

### Python

Disclaimer: The above Problem (Day 12: Inheritance) is generated by Hacker Rank but the Solution is Provided by Learnkro. This tutorial is only for Educational and Learning Purpose.