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 次查看(过去 30 天)
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------
-------E---------------<60----------
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.

回答(3 个)

Ahmet Cecen
Ahmet Cecen 2016-11-2
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
Thorsten 2016-11-2
编辑:Thorsten 2016-11-2
function g = grade(num)
if num < 60
g = 'E'
elseif num < 70
g = 'D'
and so on.

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

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by