Create a program with a script that calls the following functions: getinput, calculateGPA, createBor, and printResults. The program is to ask the user how many semesters they have received grades in college. It will then will ask for each semesters GPA and number of units taken. Be sure to include an error check to ensure that all GPA's are between 0.00 and 4.00. 3. The script will then call the function, calculateGPA, to find the cumulative GPA for the user. Next, make a function, createBar, that creates a bar graph showing each GPA entered by semester. Please note that units do not need to be included/displayed. Finally, be sure to print the results to the screen in a user-friendly manneralhiv When printing the results, depending on the cumulative GPA, provide a comment based on how they are progressing through college. -3 your are averag How many semesters in Coege what was your semester 1 &PA, How many mids did yow tke tor semester 1 ?

Respuesta :

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