We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public Student(string firstName,string lastName,int id,int[] scores):
base(firstName,lastName,id)
{
testScores=scores;
}
public char Calculate()
{
int avg= testScores.Sum() /testScores.Count();
switch(avg)
{
case int n when n>=90 && n<=100:
return 'O';
break;
case int n when n>=80 && n<90:
return 'E';
break;
case int n when n>=70 && n<80:
return 'A';
break;
case int n when n>=55 && n<70:
return 'P';
break;
case int n when n>=40 && n<55:
return 'D';
break;
case int n when n<40:
return 'T';
break;
default :
return ' ';
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 12: Inheritance
You are viewing a single comment's thread. Return to all comments →
in c#
class Student : Person{ private int[] testScores;
}