Write a simple program called Prob5m which will prompt the u
Write a simple program called Prob5.m, which will prompt the user to input test scores for a class. Your program should compute the letter grades using the following rules: score > 80 => A, 65-80 => B, 50-65=> C, 40-50 => D, and <40 => F. Your program should also compute the number of A, B, C, D, and F grades in the class. You may use the following data set to debug your program: [62 75 81 54 36 47 74 62 57 95]. Save your program under the name ‘Prob5.m’
Please solve using MATLAB
Solution
MATLAB CODE:
clc;
clear all;
close all;
prompt =\'Enter Test Score : \';
score= input(prompt);
for i=1:length(score)
if(score(i)>80)
Grade(i)=\'A\';
elseif(score(i)>65 && score(i)<=80)
Grade(i)=\'B\';
elseif(score(i)>50 && score(i)<=65)
Grade(i)=\'C\';
elseif(score(i)>40 && score(i)<=50)
Grade(i)=\'D\';
else
Grade(i)=\'F\';
end
end
fprintf(\'\ \\t Score \\t\\t Grade\ \');
for i=1:length(score)
fprintf(\'\\t %d \\t \\t %c\ \',score(i),Grade(i));
end
OUPUT:
Enter Test Score : [62 75 81 54 36 47 74 62 57 95]
Score Grade
62 C
75 B
81 A
54 C
36 F
47 D
74 B
62 C
57 C
95 A

