3) Note: you can use the mean() function for this problem. A teacher has the fol
ID: 3594920 • Letter: 3
Question
3) Note: you can use the mean() function for this problem.
A teacher has the following spreadsheet:
(3a) Create a 5x1 array called mean_quiz_scores containing the mean scores from all 5 quizzes.
(3b) Create an 3x1 array called mean_student_scores containing the mean scores for all three students.
(3c) Determine the mean score for all quizzes and students (the mean of all 15 values in the table) by taking the mean of both mean_quiz_scores and mean_student_scores. Did you get the same answer?
(3d) If the average score of Quiz 5 is greater than the average score of Quiz 4, print "Quiz 5 was easy" to the screen.
(3e) There are 15 total quizzes (3 students x 5 quizzes).
- If student 3 had the highest quiz score out of all 15 quizzes, print "Student 3 is my hero" to the screen.
- If he did not have the highest quiz score, print "Student 3 is a zero" to the screen.
(Determine who has the highest individual score using your MATLAB program, don't just read it off the table with your eyes.)
Explanation / Answer
The script has been written as desired. Please upvote my answer if you find it useful.
---------The script--------
% Quiz scores as given
quiz_scores = [99 85 67;
90 65 69;
98 95 97;
80 85 89;
98 77 87];
% Question 3a
mean_quiz_scores = mean(quiz_scores,2);
% Question 3b
mean_student_scores = mean(quiz_scores,1);
% Question 3c
mean_score_1 = mean(mean_quiz_scores);
mean_score_2 = mean(mean_student_scores);
% The below print statements show that the answer for question 3c is yes
% They can be commented out if not needed
fprintf('Mean using mean_quiz_scores: %f ',mean_score_1);
fprintf('Mean using mean_student_scores: %f ',mean_score_2);
% Question 3d
if mean_quiz_scores(5)>mean_quiz_scores(4)
fprintf('Quiz 5 was easy ');
end
%Question 3e
highest_scorers = [1];
highest_score = quiz_scores(1,1);
for i=1:5
for j=1:3
if quiz_scores(i,j)>highest_score
highest_score = quiz_scores(i,j);
highest_scorers = [j];
elseif quiz_scores(i,j)==highest_score && ~ismember(j,highest_scorers)
highest_scorers = [highest_scorers j];
end
end
end
if ismember(3,highest_scorers)
fprintf('Student 3 is my hero ');
else
fprintf('Student 3 is a zero ');
end
------Output------
Mean using mean_quiz_scores: 85.400000
Mean using mean_student_scores: 85.400000
Quiz 5 was easy
Student 3 is a zero
Please note that my script assumes that if there are multiple highest scorers, and 3 is one of them, he would be considered a hero. If this is not what you need, let me know and I'll make the desired changes.
Have a good day!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.