! program to calculate student GPA grade implicit none integer :: no_of_courses real :: grade_point_obtain=0.0, total=0.0, G_P_A=0.0 integer :: course real, dimension[:], allocatable :: credit real, dimension[:], allocatable :: grade print*, 'enter number of courses offered' read*, no_of_courses allocate(credit(1:no_of_courses)) allocate(grade(1:no_of_courses)) do course=1,no_of_courses print*, 'type in the credit_load and grade for each subject', course read*, credit(course), grade(course) total=total+credit(course) grade_point_obtain=total+(grade(course)*credit(course)) enddo
G_P_A=grade_point_obtain/total print*, 'the total credit_load is', total print*, 'the total grade_point_obtain is', grade_point_obtain print*, 'your GPA is', G_P_A
deallocate(credit) deallocate(grade)
end
the program code above to calculate a student's GPA is running but i am having a logical error,what i mean is that when i run it the total credit load is correct but the grade _point_obtain happened not to be correct, i have tried to correct this but to no avail. pls help, if possible run and confirm. thanks
below is a piece of the program when run:
enter number of courses offered 3 type in the credit_load and grade for each subject 1 3,4 type in the credit_load and grade for each subject 2 3,2 type in the credit_load and grade for each subject 3 3,5 the total credit_load is 9.00000 the total grade_point_obtain is 24.0000 your GPA is 2.66667
Press RETURN to close window . . .