% marks co370 fall/97
%  The marking scheme can be seen at the bottom of this file.
%  The final mark will be calculated using this file.
% The final mark will be added as soon as the exam period is over.

% marks co370 fall/97
maxmark = [100  30 100 60 100 30  80 100 80  92         10^8];
%        % Proj A1 C1  A2  C2 A3  M  C3  A4  Final-exam idno.
M = [
85 22 45 50 87 28 75 80 70  60 -88041901 %
85 14 45 52 87 17 39 80 80  44 -92059669 %
86 30 85 45 90 21 66 80 60  55 -93007331 %
77 11 80 14 90 27 39 80 67  43 -93025218 %
94 27 80 35 85 30 44 95 70  44 -93036337 %
86 22 10 20 67 22 71 72 60  68 -93039591 %
77 26 80 35 90 28 45 80 70  69 -93039641 %
86  0 10 23 67 18 52 72 60  31 -93043931 %
77 22 80 30 90 28 63 80 60  65 -93051258 %
94 26 80 45 85 28 58 95 70  51 -93056097 %
86 21 80 40 70 28 67 70 65  80 -93060084 %
86 25 80 50 70 25 63 70 70  70 -93069807 %
86 26 80 35 70 28 62 70 70  70 -93072316 %
94 28 85 50 90 28 90 57  0  64 -93077768 %
86 24 85 45 90 24 54 80 63  64 -93109214 %
85 21 45 55 87 21 46 80 75  48 -93120120 %
89  5 65 27 65 18 54 85 60  42 -93120504 %
88  0 40  0 73  0 56 80  0  64 -93126892 %
89 20 65 25 65 17 63 85 65  37 -93135317 %
93 25 90 35 95 24 70 95 73  60 -93136439 %
86 21 10 45 67 20 61 72 20  34 -93146928 %
93 28 90 57 95 25 71 95 60  69 -93151533 %
94 26 80 47 85 28 38 95 70  54 -93151669 %
52 25 75 32 70 27 61 85 63  62 -93152553 %
52 22 75 37 70 25 29 85 63  50 -93154167 %
93 26 90 50 95 28 53 95  0  46 -93156993 %
52 21 75 14 70 19 40 85 62  56 -93159653 %
94 29 85 60 90 28 74 57 77  80 -93170642 %
86 30 85 45 90 24 79 80 60  69 -93170862 %
81 26 20 45 77 20 79 80 80  92 -94006325 %
73 29 70 50 91 22 51 83 60  55 -94032841 %
67 23 50 30 63 19 57 60  0  53 -94037065 %
82 30 90 50 95 28 89 80 70  92 -94037495 %
91 28 50 30 75 28 53 75 60  50 -94040258 %
86 26 60 45 70 28 53 70 65  62 -94041016 %
86 27 30 36 71 18 70 78 60  46 -94042188 %
88 27 30 58 84 17 60 80 65  63 -94044061 %
88 23 40 45 73 20 68 80 60  53 -94045720 %
66 11 50 20 55 13 32 35 60  38 -94045904 %
86 24 60 35 70 26 62 70 65  53 -94051616 %
88 25 30 60 84 18 40 80 65  57 -94052848 %
94 29 85 50 90 28 55 57 62  57 -94075178 %
86 26 30 37 71 18 49 78 60  77 -94078161 %
82 25 20 22 72 28 65 90 68  61 -94078956 %
91 24 50 40 75 28 62 75 67  52 -94088779 %
82 26 20 37 72 23 52 90 40  56 -94088992 %
91 26 50 45 75 30 53 75 70  46 -94090039 %
86 19 60 50 70 26 54 70 65  68 -94091270 %
73  0 70  0 91  0 39 83  0   0 -94092361 %
89 23 65 35 65 12 88 85 65  91 -94105307 %
88 20 40 32 73 15 58 80 60  62 -94112994 %
82 25 20 37 72 27 57 90  0  50 -94113428 %
68 27 20 38 78 13 46 85 62  49 -94129825 %
67 23 50 45 63  3 57 60 63  57 -94129870 %
81 27 20 42 77 27 78 80 70  88 -94130417 %
66 20 50 57 55 18 43 35 63  50 -94132783 %
73 27 70 47 91 18 88 83 70  94 -94141616 %
81 28 20 40 77 28 43 80 75  38 -94148233 %
67 24 50 45 63 20 75 60 80  68 -94152163 %
0  17 90  0 95  9 34 80  0   0 -94163445 %
68 25 20 34 78 26 71 85 62  45 -94168709 %
66  0 50 40 55  0 42 35 60  66 -94173369 %
88 25 30 40 84 26 55 80 60  37 -94180952 %
68 25 20 30 78 29 52 85 42  82 -94181270 %
82 24 90  8 95 18 42 80  0  47 -95098728 %
86  0 10 35 68  5 47 70  0  59 -95126468 %
86 20 10  0 68  0 60 70  0  48 -95152587 %
86 26 10 42 68 18 55 70 45  60 -95206238 %
];
%
maxmark = [100  30 100 60 100 30  80 100 80  92        10^8];
%        % Proj A1 C1  A2  C2 A3  M  C3  A4  Final-exam idno.
M(:,11)=-M(:,11);   % Use - as an indicator but change to +
N = zeros(size(M));
N = M>N;
N =sum(N);   % The number of students who handed in each assignment.

AVERAGE = sum(M)./N./maxmark*100;

disp([sprintf('\n\tProj.\tAss.#1\tCase.#1\tAss.#2\tCase #2\tAss.#3\tMidterm\tCase #3\tAss.#4\tFinal')]);
disp([sprintf('\n\t%5.2f\t%5.2f\t%5.2f\t%5.2f\t%5.2f\t%5.2f\t%5.2f\t%5.2f',AVERAGE(1:10))]);
%
%
M0=M(:,1:11);   
M0(:,1)=M0(:,1)+.05*M0(:,3);   % add on 5 percent bonus from case1
M1=M0/diag(maxmark);
cases1=M1(:,[3 5 8])';
cases2=sort(cases1);
cases=cases2([2 3],:)';
cases=cases*diag([7.5 7.5]);
wts=[25 2.5 0 2.5 0 2.5 20 0 2.5 30 0];
M2=M1*diag(wts);
totmark1=sum(M2')+sum(cases');
totmark1=totmark1';
finaldata =[totmark1 M1(:,11)];   % change 10 to 11 after final mark added?
disp([sprintf('\n\tFinal Grade\tUser ID')]);
finaldata(:,1)=round(finaldata(:,1));
finaldata(:,2)=10^8*(finaldata(:,2));
for i=1:size(finaldata,1),
disp([sprintf('\t%9.0f\t%9.0f',finaldata(i,:) )]);
%disp([sprintf('\n\t%9.0f\t%9.0f',finaldata(i,:) )]);
end
figure(1);
clf
hist(finaldata(:,1),20);
xlabel('final grades');
figure(2);
clf
hist(M(:,10),20);
xlabel('final exam');
fail=find(finaldata(:,1)<50);
failid=finaldata(fail,:);
disp([sprintf('\n\tAverage for Final Grades')]);
disp([sprintf('\n\t%9.0f',mean(finaldata(:,1)) )]);
