Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. I need help with this homework which i really don\'t know how to do it. I

ID: 3769446 • Letter: H

Question

Hello. I need help with this homework which i really don't know how to do it. It's about making a small program using MATLAB. I will learn how to do it by seeing your work, that will answer all my doubts on how to make this.

Here are the homework intructions: "Create a program which allows the user to enter all his grades in vector form ( enter your grades inside a square bracket), then get the average grade.

P = Sum(grades)/lenght(grades);

If you obtain A,B,C or F.

In any case, you will receive a sentence with your average grade (percentage)."

Those are the instructions of the homework! (NOTE: Please allow me to use your work to RUN it on my MATLAB. That way i can see how it "RUN" and learn from it.) Thanks and have a nice day!

Explanation / Answer

if you enter numberic grades then the program is

R = input('enter your grades inside a square bracket');% this will read the input from terminal
avg = sum(R)/ length(R); % this will calculates the avrage of grades

disp(avg) % displays the average

if the user enter the grades in alphabets the code will be

r = input(' enter your grades inside a square bracket (Ex:[A B C] all capital letters):','s');% read a string
s=uint8(r); %converts string to vector of numbers
na = length(find(s==int8('A'))); % find the number of A grades
nb = length(find(s==int8('B'))); % find the number of B grades
nc = length(find(s==int8('C'))); % find the number of C grades
nd = length(find(s==int8('D'))); % find the number of D grades
nf = length(find(s==int8('F'))); % find the number of F grades
total = na*10 + nb*9 + nc*8 + nd*7; % calculate sum of total grades
no_of_grades = na+nb+nc+nd+nf; % total number of subjects
avg = total / no_of_grades;% calculate average
disp('avarage of all grades ')
disp(avg*10) % diplay average in percentage

Output: