forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay12:Inheritance.java
More file actions
33 lines (33 loc) · 803 Bytes
/
Day12:Inheritance.java
File metadata and controls
33 lines (33 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Student extends Person{
private int[] testScores;
Student(String firstName, String lastName, int identification,int[] scores){
super(firstName,lastName,identification);
testScores = new int[scores.length];
testScores=scores;
}
public int average(){
int sum=0;
int l=testScores.length;
for(int i=0;i<l;i++){
sum+=testScores[i];
}
return sum/l;
}
public char calculate(){
int a=average();
char grade;
if(a>=90)
grade='O';
else if(a>=80)
grade='E';
else if(a>=70)
grade='A';
else if(a>=55)
grade='P';
else if(a>=40)
grade='D';
else
grade='T';
return grade;
}
}