By Matlab please The overall grade in a course is determined from the grades of
ID: 3808826 • Letter: B
Question
By Matlab please The overall grade in a course is determined from the grades of 10 homework assignments, 2 midterms, and a final exam, using the following scheme: Homeworks: Homework assignments are graded on a scale from 0 to 80. The grade of the two lowest assignments is dropped and the average of the 8 assignments with the higher grades constitutes 20% of the course grade. Midterms and final exam: Midterms and final exams are graded on a scale from 0 to 100. If the average of the midterm scores is higher than, or the same as, the score on the final exam, the average of the midterms constitutes 40% of the course grade and the grade of the final exam constitutes 40% of the course grade. If the final exam grade is higher than the average of the midterms, the average of the midterms constitutes 30% of the course grade and the grade of the final exam constitutes 50% of the course grade. Write a computer program in a script file that determines the course grade for a student. The program first asks the user to enter the 10 homework assignment grades (in a vector), two midterm grades (in a vector), and the grade of the final. Then the program calculates a numerical course grade (a number between 0 and 100). Execute the program for the following cases: (a) Homework assignment grades: 65, 79, 80, 50, 71, 73, 61, 70, 69, 74. Midterm grades: 83, 91. Final exam: 84. (b) Homework assignment grades: 70, 69, 83, 45, 90, 89, 52, 78, 100, 87. Midterm grades: 87, 72. Final exam: 90.Explanation / Answer
Answer:
Note: The below matlab code is explained with comments followed by the symbol %.
Matlab code:
prompt= 'Enter 10 assignment grades as a vector';
x=input(prompt); % take input from user (10 assignment grades)
prompt1='Enter two mid term grades as a vector';
m=input(prompt1); % take input from user (2 mid term grades)
prompt2='Enter grade of the final exam';
f=input(prompt2); % take input from user (final exam grade)
k=sort(x,2); % sort the vector x
sum=0; % initialize sum =0
for i=3:10
sum=sum+k(i); % caluculate the sum of top 8 assignment grades
end
avg=sum/8; % caluculate average of top 8 assignment grades
t1=avg*(20/80); % 20 percent of course grade
avg1=(m(1)+m(2))/2; % average of two mid term gades[
if(avg1>=f) % if mid term average greater than final grade
t2=avg1*(40/100); % mid term grade is 40 percent of course grade
t3=f*(40/100); % final grade is 40 percent of course grade
else % else
t2=avg1*(30/100); % mid term grade is 30 percent of course grade
t3=f*(50/100); % final grade is 50 percent of course grade
end
p=t1+t2+t3; % sum of assignment grade,mid term grade and final grade
disp('The numerical course grade is :');
disp(p); % display numerical course grade
Output for (a):
>> grade
Enter 10 assignment grades as a vector[65 79 80 50 71 73 61 70 69 74]
Enter two mid term grades as a vector[83 91]
Enter grade of the final exam84
The numerical course grade is :
86.5563
Output for (b):
>> grade
Enter 10 assignment grades as a vector[70 69 83 45 90 89 52 78 100 87]
Enter two mid term grades as a vector[87 72]
Enter grade of the final exam90
The numerical course grade is :
89.6625
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.