Write a short MATLAB function. A university department provides two ways to obta
ID: 671899 • Letter: W
Question
Write a short MATLAB function.
A university department provides two ways to obtain a masters degree:
Complete a minimum of 30 graduate credit hours and write a thesis.
Complete a minimum of 36 graduate credit hours.
Write a function called hw2_can_graduate that accepts two input arguments associated to a student: hours, the number of credit hours completed , and thesis, which determines whether or not a thesis has been completed (0 for no and 1 for yes). The function determines whether or not the student can graduate with a masters degree. Return 1 if the student can graduate and 0 if not. You must include a nested if-statement.
Explanation / Answer
function d = hw2_can_graduate(ch,th)
if (ch>=36)
d=1
elseif (ch>=30) && (th==1)
d=1
else
d=0
end
end
if (hw2_can_graduate(36,0)==1)
fprintf('you have graduated congratsss!!!')
else
fprintf('Nope you need to study')
end
if (hw2_can_graduate(30,1)==1)
fprintf('you have graduated congratsss!!!')
else
fprintf('Nope you need to study')
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.