Problem:-¬†Write a Hackerrank Solution For Day 12: Inheritance or Hacker Rank Solution Program In java For ” Day 12: Inheritance ” or Hackerrank 30 days of code Java Solution: Day 12: Inheritance solution or Hackerrank solution for 30 Days of Code Challenges or Hackerrank 30 days of code Java Solution, Day 12: Inheritance solution, or Inheritance java Logic & Problem Solving: Day 12: Inheritance.

Welcome to Day 12! Check out this video reviewing inheritance, or just jump right into the problem.

You are given two classes, Student and Grade, where Student is the base class and Grade is the derived class. Completed code for Student and stub code for Grade are provided for you in the editor. Note that Grade inherits all the properties of Student.

Complete the Grade class by writing a class constructor (Grade(String,String,int,int)) and a char calculate() method. The calculate method should return the character representative of a Student’s *Grade. Score as defined in this chart:

Input Format

Input is already handled for you by the code pre-filled in the editor. There are  lines of input containing , , , and , respectively.

phone contains exactly  digits

Output Format

Output is already handled for you by the code pre-filled in the editor. Your output will be correct if your Grade class constructor and calculate method are properly written.

Sample Input


Sample Output

 First Name: Heraldo
 Last Name: Memelli
 Phone: 8135627
 Grade: O

Solution :

class Student extends Person{
	private int[] testScores;
    Student(String firstName, String lastName, int identification , int [] scores)
        super(firstName,lastName,identification );

    public String calculate()
        int sum =0;
        for(int i : this.testScores)
        double avg= sum/testScores.length;
        if (avg<=100 && avg>=90)
            return "O";
        }else if(avg<90 && avg>=80)
             return "E";
        else if(avg<80 && avg>=70)
             return "A";
        else if(avg<70 && avg>=55)
             return "P";
         else if(avg<55 && avg>=40)
             return "D";
             return "T";


Leave a Reply

Your email address will not be published.