• + 0 comments

    in c#

    class Student : Person{ private int[] testScores;

    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 ' ';
            }
    
    }
    

    }