% In order to use this M-file open a MATLAB command window and 
%    follow the instructions below

   %  a/ clear the workspace using   clear  and then type clc
   %>> clear; clc
   %  b/ run your submitted M-file as shown below (my M-file is named p1_1234.m)
   %>> p1_1234
   %  c/ run this script (M-file) by typing 
   %>> p1_chck
   %  d/ A grade will be reported at the end.
   %  Note that obviously the program won't check the validity of the first 
   %  few lines of   your submission, nor variables v1, v2, v3, v4
   %  
%
% It also does not deal with the case that a variable is not defined properly 
% (name, case, type, etc).
%
%
points=70;
clear zorro;

vv1  = 'GERBESSIOTIS alex';
vv2  = '1234';
vv3  = uint16(1234);
vv4  = int32 (1234);

vv14 = 14.141;
vv15 = single(15.1515);
vv16 = log(16/(exp(6.0)*pi^(16)));

vv17 = 17.17e7;
vv18 = 18^pi / (18 * exp(18));
vv19 = 'I like MATLAB a lot';

vv20 = 'Bloom';
vv21 = length(vv20);
vv22 = 1e6;

zorro=whos('v3');
if ((exist('v3')~=1) || isequal(v3,uint16(str2num(v2))) == false ) 
  fprintf('v3 :: %10s should be %10s\n',mat2str(v3),mat2str(uint16(str2num(v2))));
  points = points-1;
end
if ((exist('v3')~=1) || isequal(zorro.class,'uint16') == false ) 
  fprintf('v3 :: %10s should be uint16 not %30s\n',mat2str(v3),zorro.class);
  points = points-2;
end

zorro=whos('v4');
if (exist('v4')~=1) || (isequal(v4,int32(str2num(v2))) == false ) 
  fprintf('v4 :: %10s should be  %10s\n',mat2str(v4),mat2str(int32(str2num(v2))));
  points = points-1;
end
if (exist('v4')~=1) || (isequal(zorro.class,'int32') == false ) 
  fprintf('v4 :: %10s should be  int32 not %30s\n',mat2str(v4),zorro.class);
  points = points-2;
end

if (exist('v14')~=1) || (isequal(v14,vv14) == false)
  fprintf('v14::   should be %s \n',mat2str(vv14));
  points = points-5;
end
if (exist('v15')~=1) || (isequal(v15,vv15) == false)
  fprintf('v15::   should be %s \n',mat2str(vv15));
  points = points-5;
end
if (exist('v16')~=1) || (isequal(v16,vv16) == false)
  fprintf('v16::   should be %s \n',mat2str(vv16));
  points = points-5;
end
if (exist('v17')~=1) || (isequal(v17,vv17) == false)
  fprintf('v17::   should be %s \n',mat2str(vv17));
  points = points-5;
end
if (exist('v18')~=1) || (isequal(v18,vv18) == false)
  fprintf('v18::  should be %s \n',mat2str(vv18));
  points = points-5;
end

if (exist('v19')~=1) || (isequal(v19,vv19) == false)
  fprintf('v19::  wrong          \n');
  points = points-5;
end

if (exist('v20')~=1) || (isequal(v20,vv20) == false)
  fprintf('v20::  should be %s \n',mat2str(vv20));
  points = points-5;
end
if (exist('v21')~=1) || (isequal(v21,vv21) == false)
  fprintf('v21::  should be %s \n',mat2str(vv21));
  points = points-5;
end
if (exist('v22')~=1) || (isequal(v22,vv22) == false)
  fprintf('v22::  should be %s \n',mat2str(vv22));
  points = points-5;
end

fprintf(' Computed Grade for P1 is %4.1f\n',ceil(points));
