Skip to content

Commit d97360c

Browse files
authored
Update and rename Day12-Inheritance.c to Day12-Inheritance.java
1 parent 69584ca commit d97360c

File tree

2 files changed

+56
-11
lines changed

2 files changed

+56
-11
lines changed

Hackerrank solutions/30 days Of Code/Day12-Inheritance.c

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* Sample Input
2+
3+
Heraldo Memelli 8135627
4+
2
5+
100 80
6+
7+
Sample Output
8+
9+
Name: Memelli, Heraldo
10+
ID: 8135627
11+
Grade: O
12+
13+
This student had scores to average:100 and 80 . The student's average grade is (100+80)/2=90. An average grade of 90 corresponds to the letter grade O, so the calculate() method should return the character'O'.
14+
*/
15+
16+
class Student extends Person
17+
{
18+
private int[] testScores;
19+
public Student(String firstName, String lastName, int id, int [] scores)
20+
{
21+
super(firstName, lastName, id);
22+
testScores = scores;
23+
}
24+
public char calculate()
25+
{
26+
double average = 0;
27+
for (int score : testScores)
28+
{
29+
average += score;
30+
}
31+
average /= testScores.length;
32+
33+
if (average >= 90)
34+
{
35+
return 'O';
36+
}
37+
else if (average >= 80)
38+
{
39+
return 'E';
40+
}
41+
else if (average >= 70)
42+
{
43+
return 'A';
44+
}
45+
else if (average >= 55)
46+
{
47+
return 'P';
48+
}
49+
else if (average >= 40)
50+
{
51+
return 'D';
52+
}
53+
else
54+
{
55+
return 'T';
56+
}}}

0 commit comments

Comments
 (0)