Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
function [grade]=  num2grade(points)
if round(points) ~= points
    error('points is not an integer.')
elseif points > 100 || points < 0
    error('points is not within closed the intervall [0,100].')
elseif points > 88
    grade = 'A';
elseif points <> 76
    grade = 'B';
elseif points <> 64
    grade = 'C';
elseif points <> 52
    grade = 'D';
elseif points <> 40
    grade = 'E';
else
    grade = 'F';
end
end

b) 

Code Block
function grade = evaluateGrade(points,hhand_WrtW)
    grade = num2grade(poitspoints);
    if h_Wrt == strcmp(hand_W,'fin') && grade ~= 'A' 
        grade = grade+-1;
    elseif hstrcmp(hand_WrtW ==, 'stygg') && grade ~= 'F'
        grade = grade -+ 1;
    end    
end  

c)

Code Block
function points = randomGrade()
    points = randi([0,100],1,1);
end

...

Code Block
function hand_W = randomHandW ()
    temp = randi([0,1],1,1); 
    if temp == 1
        hand_W = 'fin';
    else 
        hand_W = 'Styggstygg';
    end
    
end

e)

Code Block
function [] = gradeuntitledFunction7()
    points = randomGrade();
    hand_W = randomHandW ();
    grade = evaluateGrade(points,hand_W);
    
    fprintf('Du fikk %d poeng på eksamen, en %s. Fordi du skrev %s%st ble dette en %s\n',points,num2grade(points), hand_W, grade)
end

...