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