Answer:
The script is given below
Explanation:
%%driver
[grades , num_semester ] = getInput( ) ;
gpa = calculateGPA(grades , num_semester) ;
printResult( gpa) ;
createBar( num_semester , grades ) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [grades , no_semester] = getInput()
no_semester = input("How many semesters in college " );
for i = 1: no_semester
grades(i) = input( " Enter semester GPA ") ;
if( grades(i) > 4 && grades(i) < 0 )
disp( " Entered Grades are out Of Bounds ") ;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function GPGA = calculateGPA(grades , no_semester )
sum = 0 ;
for i = 1 : no_semester
sum = sum + grades(i) ;
end
GPGA = sum/( no_semester);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function bargraph = createBar( semester_num , grades )
bargraph = bar( grades, semester_num) ;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function f = printResult( gpga )
fprintf( " Your GPGA is : %d \n " , gpga);
if( gpga >= 3 && gpga <=4 )
fprintf( " exception good work ") ;
end
if( gpga >= 2 && gpga <= 3)
fprintf( " You are average " ) ;
end
if( gpga >= 1 && gpga <= 2 )
fprintf( " you FAIL" ) ;
end
end