Write a MATLAB program to: Prompt the user to enter numeric grades (one at a tim
ID: 1716398 • 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
The MATLAB CODE IS GIVEN BELOW
---------------------------------------------------------------------------------------------------------------------------------------
clc;
disp('enter the numeric grades after the dispaly of -> and a pi in the end')
Sum=0;
Agr=0;
Bgr=0;
Cgr=0;
Dgr=0;
Fgr=0;
Max=0;
Min=100;
Count=0;
while 1
prompt='->';
x=input(prompt);
if x==pi
break
end
Count=Count+1;
if x >= 90
Agr=Agr+1;
elseif x >= 80
Bgr=Bgr+1;
elseif x >= 70
Cgr=Cgr+1;
elseif x >= 60
Dgr=Dgr+1;
else
Fgr=Fgr+1;
end
if x>Max
Max=x;
end
if x< Min
Min=x;
end
Sum=Sum+x;
end
Average=Sum/Count;
disp('Total number of students : ')
disp(Count)
disp('number of students in A-grade: ')
disp(Agr)
disp('number of students in B-grade: ')
disp(Bgr)
disp('number of students in C-grade: ')
disp(Cgr)
disp('number of students in D-grade: ')
disp(Dgr)
disp('number of students in F-grade: ')
disp(Fgr)
disp('Maximum marks: ')
disp(Max);
disp('Minimum marks: ')
disp(Min);
disp('average marks: ')
disp(Average);
---------------------------------------------------------------------------------------------------------------------------------------------
The results for 4 grade input is shown below
enter the numeric grades after the dispaly of -> and a pi in the end
->43
->56
->76
->86
->pi
Total number of students :
4
number of students in A-grade:
0
number of students in B-grade:
1
number of students in C-grade:
1
number of students in D-grade:
0
number of students in F-grade:
2
Maximum marks:
86
Minimum marks:
43
average marks:
65.2500
The results for 10 grade input is
enter the numeric grades after the dispaly of -> and a pi in the end
->35
->45
->55
->65
->75
->85
->95
->99
->16
->23
->pi
Total number of students :
10
number of students in A-grade:
2
number of students in B-grade:
1
number of students in C-grade:
1
number of students in D-grade:
1
number of students in F-grade:
5
Maximum marks:
99
Minimum marks:
16
average marks:
59.3000
The results for 20 garde input is
enter the numeric grades after the dispaly of -> and a pi in the end
->23
->25
->27
->35
->56
->67
->69
->73
->76
->85
->81
->19
->92
->87
->99
->54
->50
->56
->81
->93
->pi
Total number of students :
20
number of students in A-grade:
3
number of students in B-grade:
4
number of students in C-grade:
2
number of students in D-grade:
2
number of students in F-grade:
9
Maximum marks:
99
Minimum marks:
19
average marks:
62.4000
The MATLAB CODE IS GIVEN BELOW
clc;
disp('enter the numeric grades after the dispaly of -> and a pi in the end')
Sum=0;
Agr=0;
Bgr=0;
Cgr=0;
Dgr=0;
Fgr=0;
Max=0;
Min=100;
Count=0;
while 1
prompt='->';
x=input(prompt);
if x==pi
break
end
Count=Count+1;
if x >= 90
Agr=Agr+1;
elseif x >= 80
Bgr=Bgr+1;
elseif x >= 70
Cgr=Cgr+1;
elseif x >= 60
Dgr=Dgr+1;
else
Fgr=Fgr+1;
end
if x>Max
Max=x;
end
if x< Min
Min=x;
end
Sum=Sum+x;
end
Average=Sum/Count;
disp('Total number of students : ')
disp(Count)
disp('number of students in A-grade: ')
disp(Agr)
disp('number of students in B-grade: ')
disp(Bgr)
disp('number of students in C-grade: ')
disp(Cgr)
disp('number of students in D-grade: ')
disp(Dgr)
disp('number of students in F-grade: ')
disp(Fgr)
disp('Maximum marks: ')
disp(Max);
disp('Minimum marks: ')
disp(Min);
disp('average marks: ')
disp(Average);
The results for 4 grade input is shown below
enter the numeric grades after the dispaly of -> and a pi in the end
->43
->56
->76
->86
->pi
Total number of students :
4
number of students in A-grade:
0
number of students in B-grade:
1
number of students in C-grade:
1
number of students in D-grade:
0
number of students in F-grade:
2
Maximum marks:
86
Minimum marks:
43
average marks:
65.2500
The results for 10 grade input is
enter the numeric grades after the dispaly of -> and a pi in the end
->35
->45
->55
->65
->75
->85
->95
->99
->16
->23
->pi
Total number of students :
10
number of students in A-grade:
2
number of students in B-grade:
1
number of students in C-grade:
1
number of students in D-grade:
1
number of students in F-grade:
5
Maximum marks:
99
Minimum marks:
16
average marks:
59.3000
The results for 20 garde input is
enter the numeric grades after the dispaly of -> and a pi in the end
->23
->25
->27
->35
->56
->67
->69
->73
->76
->85
->81
->19
->92
->87
->99
->54
->50
->56
->81
->93
->pi
Total number of students :
20
number of students in A-grade:
3
number of students in B-grade:
4
number of students in C-grade:
2
number of students in D-grade:
2
number of students in F-grade:
9
Maximum marks:
99
Minimum marks:
19
average marks:
62.4000
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.