GMU Percentage of Passing Grade and Vectorized Operations Questionnaire

First I need you to review my answers and make sure that all of them are correct, if there are mistakes please fix them on MATLAB, Also, I need you to write all the codes on MATLAB and send them to me as .m script file.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

1. How many “else if’ statements are allowed in an “if/else if” structure. (1 point)
1
2
5
10
As many as you want
Answer: E.
a.
b.
c.
d.
e.
2. Given a vector V that contains test scored between 0 and 100 (you do not have to create V), write
MATLAB code to calculate the percentage of passing grades (>=60) in V and store it in an
appropriately named variable. (5 points)
Code:
s2 size(V);
passing_grades = 0;
for i=1:52
if V(i)>=60
passing_grades = passing_grades+1;
end
end
passing_percentage = (passing_grades/sz)*100;
3. Write a line of MATLAB code to display a menu that asks the user to select one of three food
options: pizza, hot dog, or hamburger. Store the selection in a variable called “food.” (4 points)
Extra credit: Write a switch statement that will display the choice to the command window, or
an error message if the menu was closed without selection. (+5 points)
food = input(“Enter one of these three foods: pizza, hot dog, hamburger”, ‘s’);
4. Write a MATLAB function called “PassFail” that: (10 points)
Accepts as input an integer representing a test score.
Displays a message indicating if the score passed or failed.
A score of 60 or more passes.
A score less than 60 fails.
Does not return anything,
Input validation: The program should display an error message and terminate if
the score is less than 0.
Code:
function Pass Fail(x)
if x

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER