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 Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by