I understand the point of asking a question is to not automatically be given the answer. However I have no clue how to even approach the given questions that are mentioned below. I looked up a way to do it on the Matlab website already but am lost.

1 view (last 30 days)
1.) Create a program to determine test grades based on the score and assuming a single input. The grades should be based on the following criteria -
--- Grade--------- Score--------
-------A-------------90 to 100-----
-------B-------------80 to 89------
-------C-------------70 to 79------
-------D-------------60 to 69------
2.) Create a program that prompts the user to enter his or her year in school – freshman, sophomore, junior or senior. The input will be a string. Use the switch/case structure to determine which day finals would be given for each group – Monday for freshmen, Tuesday for sophomores, Wednesday for juniors and Thursday for seniors.
3.) Create a program using for loop to calculate the factorial of an inputted number.
4.) Repeat the above problem using while loop.

Answers (3)

Ahmet Cecen
Ahmet Cecen on 2 Nov 2016
Create the functions first:
function letter = grade(points)
if this
letter = that
else if this
letter = that
so on.
Same with case structure for 2, for loop for 3, while loop for 4.

Thorsten on 2 Nov 2016
Edited: Thorsten on 2 Nov 2016
function g = grade(num)
if num < 60
g = 'E'
elseif num < 70
g = 'D'
and so on.

Image Analyst
Image Analyst on 2 Nov 2016
Another helpful snippet you can adapt:
buttonNumber = menu('Enter your class', 'Freshman', 'Sophomore', 'Junior', 'Senior')
switch buttonNumber
case 1


Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!