I have written a function to satisfy the following question for my homework:
Write a function called letter_grades that takes a positive integer called score as its input argument and returns a letter grade according to the following scale: A: 91 and above; B: 81-90; C: 71-80; D: 61-70; F: below 61. Remember that to assign a letter to a variable, you need to put it in single quotes, as in: grade = 'A'
I have written the following:
function a = letter_grades(score)
if 91 <= (score) && (score) <= 100
a = A;
elseif 81 <= (score) && score <= 90
a = B;
elseif 71 <= score && score <= 80
a = C;
elseif 61 <= score && score <= 70
a = D;
elseif 0 <= score && score <=60
a = F;
However I receive the error:
'Undefined function or variable 'A'.
Error in letter_grades (line 3)
a = A;
What exactly does this mean, and can someone please explain how and why to fix my function?
- A new, struggling and unfortunately not innately computer programmer.