Problem 111 Write and run a MATLAB function that has as inpu
Problem 11.1 Write and run a MATLAB function that has as input, a letter grade that can include + or - with the letter grades A, B, C, but not with the D or F. The output of the function is to be the numerical equivalent of the letter grade, that is an A or A+ converts to a 4, A- = 3.7, B+ = 3.3, B = 3, B- = 2.7, C+ = 2.3, C = 2, C- = 1.7, D = 1, F = 0.
Solution
Quite a simple code using switch case statement
function grades
 clc
 clear all
 
 grades= input(\'Enter number to corresponding grades 1.A+ 2.A- 3. B+ 4.B 5. B- 6.C+ 7. C 8.C- 9. D 10. F : \')   
 switch grades
 case {1}
 disp (\'CGPA = 4\')
 case {2}
 disp (\'CGPA = 3.7\')
 
 case {3}
 disp (\'CGPA = 3.3\')
 
 case {4}
 disp (\'CGPA = 3.0\')
 case {5}
 disp (\'CGPA = 2.7\')
 case {6}
 disp (\'CGPA = 2.3\')
 case {7}
 disp (\'CGPA = 2\')
 case {8}
 disp (\'CGPA = 1.7\')
 case {9}
 disp (\'CGPA = 1\')
 case {10}
 disp (\'CGPA = 0\')
 otherwise
 disp (\'Enter right option\')
 end

