Write a MATLAB program to: Prompt the user to enter numeric grades (one at a tim
ID: 1718815 • Letter: W
Question
Write a MATLAB program to: Prompt the user to enter numeric grades (one at a time) within a while loop. Any number ol grades can be entered. Determine the number of grades in each grade range using a standard 10 point scale: A (90 or higher), B (80-90), C (70-80), D (60-70). and F (0-60). Determine the maximum, minimum, and average grade. Display the results including the number ot grades, maximum grade, minimum grade, and the number of grades in each grade range. Test the program for cases including 4 grades. 10 grades, and 20 grades with the grades reasonably distributed between the grades ranges.Explanation / Answer
Open matlab; press Ctrl+N for a new script file;
Copy paste the below program;
enjoy!! :)
clear all;
clc;
n = input('Enter the number of students: ');
marks = zeros(n,1);
k=1;a=0;b=0;c=0;d=0;f=0;
while k<=n
marks(k) = input('Enter the marks: ');
if marks(k)>=90
a=a+1;
elseif marks(k)<90 && marks(k)>=80
b=b+1;
elseif marks(k)<80 && marks(k)>=70
c=c+1;
elseif marks(k)<70 && marks(k)>=60
d=d+1;
else
f=f+1;
end
k = k+1;
end
disp('maximum value = ');
disp(max(marks));
disp('minimum value = ')
disp(min(marks));
disp('average value = ')
disp(mean(marks));
disp('A graders are ')
disp(a);
disp('B graders are ')
disp(b);
disp('C graders are ')
disp(c);
disp('D graders are ')
disp(d);
disp('F graders are ')
disp(f);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.