Hello Programmers/Coders, Today we are going to share solutions of Programming problems of 30 Days Of Code, HackerRank. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Day 12: Inheritance in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Link for the Problem – Day 12: Inheritance – Hacker Rank Solution
Day 12: Inheritance – Hacker Rank Solution
Problem:
Objective
Today, we’re delving into Inheritance. Check out the attached tutorial for learning materials and an instructional video.
Task
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:

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 , , and , separated by a space. The second line contains the number of test scores. The third line of space-separated integers describes .
Constraints
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
Heraldo Memelli 8135627 2 100 80
Sample Output
Name: Memelli, Heraldo ID: 8135627 Grade: O
Explanation
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'O'
.
Day 12: Inheritance – Hacker Rank Solution
public class Student extends Person { private int[] testScores; Student(String firstName, String lastName, int id, int[] testScores) { super(firstName, lastName, id); this.testScores = testScores; } public char calculate() { int sum = 0; for (int i = 0; i < testScores.length; i++) { sum += testScores[i]; } int avg = (sum) / testScores.length; if (90 <= avg && avg <= 100) { return 'O'; } else if (80 <= avg && avg < 90) { return 'E'; } else if (70 <= avg && avg < 80) { return 'A'; } else if (55 <= avg && avg < 70) { return 'P'; } else if (40 <= avg && avg < 55) { return 'D'; } else { return 'T'; } } }
buy cialis online safely cialis daily cost buy cheap ed pills
estrace 2mg oral purchase prazosin generic buy minipress generic
cheap vermox mebendazole sale order tadalafil for sale
oral avanafil 100mg buy voltaren 50mg pill buy voltaren 50mg generic
buy indocin 75mg sale cefixime 100mg brand buy suprax
order trimox 500mg pills buy biaxin generic clarithromycin 250mg usa
clonidine price order spiriva generic tiotropium bromide 9mcg brand
minocycline 50mg cost buy cheap generic actos buy actos pill
buy arava 20mg purchase sildenafil order sulfasalazine 500mg generic
cialis 20mg pills cialis daily tadalafil online buy
stromectol order online prednisone 10mg oral deltasone 40mg for sale
ramipril 10mg brand buy glimepiride generic arcoxia usa
buy asacol 400mg pill azelastine 10ml cost buy irbesartan pill
diamox order imdur 40mg price azathioprine 50mg price