% Final Grade Computer
% Place your grades in the spots beneith the assignment name
assignments = ['HW1';'HW2';'HW3';'HW4';'HW5'];
HW_grades =    ['A+';'C-'; 'C '; 'D '; 'A '];
% Note that the field needs 2 places so that an A is 'A '
assignments = [assignments;'Q 1';'Q 2';'Q 3'];
Quiz_grades =              ['B-';'B+'; 'A+'];
% Note that the field needs 3 places so that an A is 'A '

weights = [6,6,6,6,6,20,20,30]/100;

sum(weights)
All_grades=[HW_grades; Quiz_grades];
Grade_num=[];
% This switch statement maps the grades to the real line
% any mapping will gave the same result as long as the spacing is uniform
for i=1:length(All_grades)
    switch (All_grades(i,:))
        case 'A+'
            Grade_num(i)=15;
        case 'A '
            Grade_num(i)=14;
        case 'A-'
            Grade_num(i)=13;
        case 'B+'
            Grade_num(i)=12;
        case 'B '
            Grade_num(i)=11;
        case 'B-'
            Grade_num(i)=10;
        case 'C+'
            Grade_num(i)=9;
        case 'C '
            Grade_num(i)=8;
        case 'C-'
            Grade_num(i)=7;
        case 'D+'
            Grade_num(i)=6;
        case 'D '
            Grade_num(i)=5;
        case 'D-'
            Grade_num(i)=4;
        case 'F '
            Grade_num(i)=3;
    end
end
Num_average=sum(weights.*Grade_num);
% This switch statement maps the grades back to letters
% any mapping will work as long as it matches the previous one
switch (round(Num_average))
        case 15
            FinalGrade='A+';
        case 14
            FinalGrade='A ';
        case 13
            FinalGrade='A-';
        case 12
            FinalGrade='B '; % NOTE:  the grade B+ will not exist
        case 11
            FinalGrade='B ';
        case 10
            FinalGrade='B-';
        case 9
            FinalGrade='C ';
        case 8
            FinalGrade='C ';
        case 7
            FinalGrade='C-';
        case 6
            FinalGrade='D ';
        case 5
            FinalGrade='D ';
        case 4
            FinalGrade='D ';
        case 3
            FinalGrade='F ';
    end
    FinalGrade        

