This assignment is about calculating final grades for CS2035 students given student identification (name and student number, such as John-Barron, 123456789), 11 lab grades (0 or 1), 4 assignment grades (up to 100 points) and 2 exam grades (midterm is out of 100 and final is out of 190). The assignments requires you to use for/while loops and arrays. Vectorized is not required (and in fact, discouraged). You are supplied with template code, where much of the code to perform this task is given to you in a file ass1_template_2019.m. Comments in the code indicate where you should supply code and what its functionality should be. First, I would read the supplied code completely to see what variables are supplied and get an overview of the code functionality. The program has code to read the data stored in file cs2035_ass1_2019_marks.txt on the course webpage. There are n=51 datasets with student/grade data. Student names can be any length, so an array of character strings is not feasible as then all character string must be the same length. We use a cell array, names=cell(n,1), to store arbitrary length names. It would have been nice to have used feof(fd) to detect the end of the file and have counted the number of students There is a while loop (while i exams(i,1), the final exam is greater than the midterm grade, the exam_total is computed as 0.55*exams(i,2), otherwise compute the exam_total as 0.2*exams(i,1)+0.35*exams(i,2). Note that this assumes exams(i,2) has been scaled from being out of 190 to being out of 100 by using the ratio variable. The comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % set the message character string if rule 1 (45% rule) is invoked % keep track of the number of times rule 1 is invoked %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sets the message character string variable, message, to appropriate string telling the used rule1 (as indicated by boolean variables, assign_cond1 and exam_cond1) has been invoked and the initial final grade has 1been set to 45. You could say what the original grade was before it was changed. Similarly, the comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % set the message character string if rule 2 (60% rule) is invoked % keep track of the number of times rule 2 is invoked %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sets the message character string variable, message, to appropriate string telling the used rule2 (as indicated by boolean variables, assign_cond2 and exam_cond2) has been invoked and the initial final grade has been set to 60. Again, you could say what the original grade was before it was changed. The comment: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set total and count variables for average calculations The passed_course_total, failed_course_total and passed_course_ct and failed_course_ct variables are set below %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% asks the programmer to compute total and count variables need to perform average calculations. For example: if(final(i) >= 50) passed_course_total=passed_course_total+final(i); passed_course_ct=passed_course_ct+1; end computes the total passed course grades and the number of passed students. At the end of the for i loop we can then compute the passed_course_average (see below), The comment: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% compute the counts for >=90, >=80, >=75, >=70, >=65, >=60, >=55, >= 50, in the range 1 and 49 and 0 - this code required a nested if-then-else statement %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% used the preallocated count array for each grade range using: if(final(i) >= 90) count(1)=count(1)+1 elseif(final(i)>=80) count(2)=count(2)+1 elseif(final(i)>=75) count(3)=count(3)+1 ... else count(9)=count(9)+1; end Note that below, the grade distribution is printed as: fprintf('\n\nFinal Grade distribution:\n'); fprintf('90-100: %2d\n',count(1)); fprintf(' 80-89: %2d\n',count(2)); fprintf(' 75-79: %2d\n',count(3)); fprintf(' 70-75: %2d\n',count(4)); fprintf(' 65-69: %2d\n',count(5)); fprintf(' 60-64: %2d\n',count(6)); fprintf(' 55-59: %2d\n',count(7)); fprintf(' 50-54: %2d\n',count(8)); fprintf(' 1-49: %3d\n\n',count(9)); At this point, the "for i=1:n" loop is ended. After the "for i=1:n" loop, the averages are computed and printed. For example: fprintf('Passed final average: %5.2f for %d students\n',... passed_final_exam_total/passed_final_exam_ct,passed_final_exam_ct); Thats all you have to do!