%Problem set part 2::Using for-loops in matlab
%Calculate grades equivalent

%create grades vector
% instead of using random function you can manually enter values
grades=randi([20,100],[1,20]);

%initialize gradesEquivalent
gradesEquivalent=char(zeros(1,20));

for index=1:length(grades)
    if (grades(index)>=90)
        gradesEquivalent(index)='A';
    elseif (grades(index)>=80)
        gradesEquivalent(index)='B';
    elseif (grades(index)>=70)
        gradesEquivalent(index)='C';
    elseif (grades(index)>=60)
        gradesEquivalent(index)='D';
    else
        gradesEquivalent(index)='E';
    end
end

% print the grades
fprintf('%3d',grades);
fprintf('\n');

% print the gradesEquivalent
fprintf('%3c',gradesEquivalent);
fprintf('\n');
