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

Create a program that will calculate a student\'s GPA using switch statements. T

ID: 670542 • Letter: C

Question

Create a program that will calculate a student's GPA using switch statements. The program should prompt the user for the number of courses (which determines a for loop counter). Then the program will ask for the letter grade (string variable) and the credit hours for that course. It will take those inputs and then calculate the student's GPA based on the following 4.0 grading scale. Add the credit hours and the grade point hours on each pass through the loop. Upon completion of the loop, calculate the final grade point average (grade point hours/credit hours). Hint: keep 2 scalar running totals in the loop: (1) total_hours, and (2) total_earned

Explanation / Answer

Matlab program that prompts grade pointer and total houres for number of coureses

and print the average grade point.

average.mat

%clear the previous variables
clear
count=input('enter number of courses')
%for loop to count from 0 to count
for i = 0 : count
   %two scalar variables
   total_hours=0
   total_earned=0  
   %read grade and hours
   grade=input('enter grade value', 's')
   hours=input('enter credit hours')
  
   %check switch case statement then add the total_hours with correcsponding
   %value
   switch(grade)
  
   case 'A':
   total_hours=total_hours+4.0
   case 'A-':
   total_hours=total_hours+3.7
   case 'B+':
   total_hours=total_hours+3.3
   case 'B':
   total_hours=total_hours+3.0
   case 'B-':
   total_hours=total_hours+2.7
   case 'C+':
   total_hours=total_hours+2.3
   case 'C':
   total_hours=total_hours+2.0
   case 'C-':
   total_hours=total_hours+1.7
   case 'D+':
   total_hours=total_hours+1.3
   case 'D':
   total_hours=total_hours+1.0
   case 'D-':
   total_hours=total_hours+0.7
   case 'E':
   total_hours=total_hours+0.0
   end
   %add hours to total_earned  
   total_earned=total_earned+hours

end

%print string
display('Average grade point')
%set for two decimal values
format bank
%print average by dividing total_hours/ total_earned
disp(total_hours/total_earned)

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