List of midterm and final exam scores of 30 students are given as follow midterm
ID: 3588656 • Letter: L
Question
List of midterm and final exam scores of 30 students are given as follow midterm_grades (61, 8, 92, 35, 57, 88, 91, 83, 61, 86, 90, 99, 55, 63, 53, 98, 46, 97, 62, 71, 49, 79, 46, 92, 89, 99, 71, 69, 59, 74 final-grades = [66, 98, 84, 75, 73, 83, 41, 87, 96, 41, 90, 87, 100, 54. 96, 79, 47, 57, 86, 89, 47, 69, 54, 96, 60, 92 86, 93. 52, 861 Write a MATLAB script to answer the following questions: I. What is the weighted score of each student, which is based on 40% of midterm and 60% of final. 2. How many students passed the course (passing policy is achieving at least 60 in the final exam and at least 70 for weighted score) 3. How many students passed the course despite failing the midterm (midterm score less than 60). 4. What is the average weighted score of those students who passed the course Use the command fprintf to display the results.Explanation / Answer
midterm_grades = [61,80,92,35,57,88,91,83,61,86,90,99,55,63,53,98,46,97,62,71,49,79,46,92,89,99,71,69,59,74];
final_grades = [66,98,84,75,73,83,41,87,96,41,90,87,100,54,96,79,47,57,86,89,47,69,54,96,60,92,86,93,52,86];
weighted_score = [];
% calculate weighted_score of students
for i=1:length(midterm_grades)
weighted_score = [weighted_score,midterm_grades(i)*0.4 + final_grades(i)*0.6];
end
passed = 0;
midfail = 0;
average = 0;
for i=1:length(weighted_score)
% condition to check passed students
if(weighted_score(i)>70 && final_grades(i)>60)
passed = passed+1;
% add weighted_score of passed students to average
average = average + weighted_score(i);
% check the midtem_grades of passed students
if(midterm_grades(i)<60)
midfail = midfail+1;
end
end
end
fprintf("Weighted scores of students ")
fprintf("%d ",weighted_score);
fprintf(" ");
fprintf("Students passed the course:%d ",passed)
fprintf("Students passed the course despite failing the midterm:%d ",midfail)
fprintf("Average weighted score of passed students:%d ",average/passed);
% sample output
%Weighted scores of students
%64 90.8 87.2 59 66.6 85 61 85.4 82 59 90 91.8 82 57.6 78.8 86.6 46.6 73 76.4 81.8 47.8 73 50.8 94.4 71.6 94.8 80 83.4 54.8 81.2
%Students passed the course:18
%Students passed the course despite failing the midterm:2
%Average weighted score of passed students:84.7
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.