Write a junction called classAverage that takes in an array of numbers and, afte
ID: 3624716 • Letter: W
Question
Write a junction called classAverage that takes in an array of numbers and, after normalizing the grades in such a way that the highest corresponds to 100, returns the letter grade of the class average. This curve is the same method used to generate in Chapter Problem 2. The grade ranges are as follows: average>90 => A 80 le average B 70 le average C 60 le average D average F For example: classAverage ( [70 87 95 80 80 78 85 90 65 99 ... 89 100] ) should return B classAverage ( [50 90 61 82 75 92 81 76 87 41 ... 31 98] ) should return C classAverage ( [10 10 11 32 53 12 34 74 31 30 ... 26 21] ) should return yExplanation / Answer
grades =
70 80 75 85 90 95 100
function averagegrade= classAverage(grades)
max1= max(grades);
grades2= (grades/max1)*100;
classAvg= mean(grades2);
if classAvg >= 90 && classAvg<100
averagegrade= 'A';
elseif classAvg >= 80 && classAvg<90
averagegrade= 'B';
elseif classAvg >= 70 && classAvg<80
averagegrade= 'C';
elseif classAvg >= 60 && classAvg<70
averagegrade= 'D';
elseif classAvg >= 0 && classAvg<60
averagegrade='F';
end
end
Output:
>> averagegrade= classAverage(grades)
averagegrade =
B
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.