Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a user defined function in \"matlab\" that calculates the user\'s grade po

ID: 671281 • Letter: W

Question

Write a user defined function in "matlab" that calculates the user's grade point average, where A=4, B=3, C=2, D=1, F=0. Test your function using the grades and credit hours shown in the table below. The code must be written so that the user can inter their grades and credit hours.

Grades          Credit hours

B                         2

B                         4

A                         3

D                         4

A                          3

B                         4

D                        3

B                         4

Explanation / Answer

function Gpa = matlab()
t=0
s=0
g=0
for i=1:8
grade=input("Enter the grade: ",'s')
cHours=input("Number of credi hours: ")
if grade=='A'
t=4
elseif grade=='B'
t=3
elseif grade=='c'
t=2
elseif grade=='D'
t=1
else
t=0
end
s=s+cHours
g=g+t*cHours
end
g=g/s
Gpa=g
end

l=matlab()
fprintf("Gpa= %fN",l)
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote