Question: Matlab Write a function that takes in a numeric grade and returns a letter grade. 90+ is an A, 80-90 is a B, anything below
Matlab



Write a function that takes in a numeric grade and returns a letter grade. 90+ is an A, 80-90 is a B, anything below that is a C.* As before, we'll test this function by calling it from the command window.* Extra credit: Add in for > X7.5 and that's an A o Check if the grade is larger than 80->that's a B o Otherwise, a C Extra credit: The point is to do this without just using a huge number of if statements. That way, if you were to add in additional letter grades (D and F) or change the boundaries (to 0.3 and 0.7) the code would be easy to change. o Calculate the "left over"- e.g. (grade -80) for a B grade+ o After you assign the main letter grade, add in the or 'to the current letter, based on the value of the left over. I.e., if the leftover were less than 0.25, you would add a to the 'B' string Self-check: - >> str = LetterGrade (95)+' str =+' A J >> str = LetterGrade(85)+' str =+' B J >> str = LetterGrade (75)+' str =+' CJ EXTRA CREDIT: J >> str = LetterGrade( 98)+' >> str Letter Grade(-82) +' = B-J
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
