Write a MATLAB script to process student grades. Example execution: Enter studen
ID: 3695113 • Letter: W
Question
Write a MATLAB script to process student grades.
Example execution:
Enter student lab average (negative to end):70
Enter student program average:80
Enter student lab average (negative to end):70
Enter student program average:90
Enter student lab average (negative to end):85
Enter student program average:75
Enter student lab average (negative to end):70
Enter student program average:75
Enter student lab average (negative to end):-1
Number of students: 4
Average for all students: 76.875000
Student averages above the class average:
student: 2 average: 80.000000
student: 3 average: 80.000000
Requirements:
1. You must match the output shown above
2. Have a clear statement at the start your script to clear previous variables.
3. After grades are put into the array, process the matrix with a loop to display students with an average above the class average. The student number displayed is the index of that student in the array
4. Read the grades into a two dimensional array.
Each row contains:
Column 1: student lab average
Column 2: student program average
Column 3: student class average. Labs and programs averages each count 50% towards the class average.
Explanation / Answer
a=[];
s=0;
while true
x = input("Enter student lab average (negative to end):");
if x<0
break
end
y = input("Enter student program average:");
avg = (x+y)/2;
s+=avg;
b = [x,y,avg];
a = [a;b];
end
count = size(a)(1);
disp(["Number of students: ",num2str(count)]);
avg = s/count;
disp(["Average for all students: ",num2str(avg)]);
disp("Student averages above the class average:");
for i=1:size(a)(1)
if a(i,3)>avg
disp(["student: ",num2str(i)," average: ",num2str(a(i,3))]);
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.