MATLAB grade problem

I just learned matlab and my coding can be considered quite long since I code it one by one. Can someone help me to improvise my coding ?

Develop a MATLAB program that input for students’ final grades in a given class (the grades are
integer values in the range 1-9) after each time the program prompts "Do you want enter more
Grade Y/N :" until user press N. The program then displays the class grade average, the highest
grade, and how many students in the class failed the course (a grade less than 4 is a failing grade).


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

count = 0;
sum = 0;
fails = 0;
maxgrade = 0;
resume = 'y';

    while (resume == 'y')
    grade = input('Enter students grade: ');
        if (grade < 4)
            fails = fails + 1;
            sum = sum + grade;
            count = count + 1;
                if (grade > maxgrade)
                maxgrade = grade;
                end
        elseif (grade < 10 & grade > 3)
            sum = sum + grade;
            count = count + 1;
                if (grade > maxgrade)
                maxgrade = grade;
                end
        else
            disp('Invalid grade');
        end
    
    resume = input('Do you want enter more Grade Y/N : ', 's');
    
    end
    
avg = sum/count;
fprintf('Class average: %.2f', avg);
fprintf('\nHighest Grade: %d', maxgrade);
fprintf('\nNumber of student that failed the course: %d\n', fails)
Morning,
You could try a matlab forum, rather than a c++ one?
Topic archived. No new replies allowed.