I want the script file in matlab Write a script file that c

. I want the script file in matlab.

Write a script file that computes theGPA for a list of courses. The number of courses can vary. The credits for each course can vary. Shaded grading should be used.The script should ask for a letter grade and then ask for the associated credits.It will then repeat as needed.The script should ask for new courses until the user inputs a blank(indicating they are done).If the user makes a typo a message should be printed and the program should continue.The script should output the total grade points, the total credits, and the resulting GPA.

Solution

%matlab script

totalCredits = 0;
totalGradePoints = 0;

while true
courseName = input(\'Enter course name: \', \'s\');
if isempty(courseName)
break
end
  
grade = input(\'Enter letter grade: \', \'s\');
credits = input(\'Enter credits: \');
  
if grade == \'A\'
totalGradePoints = totalGradePoints + 5*credits;
elseif grade == \'B\'
totalGradePoints = totalGradePoints + 4*credits;
elseif grade == \'C\'
totalGradePoints = totalGradePoints + 3*credits;
elseif grade == \'D\'
totalGradePoints = totalGradePoints + 2*credits;
elseif grade == \'E\'
totalGradePoints = totalGradePoints + 1*credits;
else
totalGradePoints = totalGradePoints + 0;
end
  
totalCredits = totalCredits + credits;
end


GPA = totalGradePoints/totalCredits;
fprintf(\'GPA: %0.2f\ \',GPA);


%{
output:

Enter course name: maths
Enter letter grade: A
Enter credits: 3
Enter course name: bio
Enter letter grade: C
Enter credits: 4
Enter course name: chemistry
Enter letter grade: B
Enter credits: 3
Enter course name:
GPA: 3.90

%}

%matlab script

totalCredits = 0;
totalGradePoints = 0;

while true
courseName = input(\'Enter course name: \', \'s\');
if isempty(courseName)
break
end
  
grade = input(\'Enter letter grade: \', \'s\');
credits = input(\'Enter credits: \');
  
if grade == \'A\'
totalGradePoints = totalGradePoints + 5*credits;
elseif grade == \'B\'
totalGradePoints = totalGradePoints + 4*credits;
elseif grade == \'C\'
totalGradePoints = totalGradePoints + 3*credits;
elseif grade == \'D\'
totalGradePoints = totalGradePoints + 2*credits;
elseif grade == \'E\'
totalGradePoints = totalGradePoints + 1*credits;
else
totalGradePoints = totalGradePoints + 0;
end
  
totalCredits = totalCredits + credits;
end


GPA = totalGradePoints/totalCredits;
fprintf(\'GPA: %0.2f\ \',GPA);


%{
output:

Enter course name: maths
Enter letter grade: A
Enter credits: 3
Enter course name: bio
Enter letter grade: C
Enter credits: 4
Enter course name: chemistry
Enter letter grade: B
Enter credits: 3
Enter course name:
GPA: 3.90

%}

. I want the script file in matlab. Write a script file that computes theGPA for a list of courses. The number of courses can vary. The credits for each course
. I want the script file in matlab. Write a script file that computes theGPA for a list of courses. The number of courses can vary. The credits for each course

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site