! A fortran95 program for G95
! By WQY
program main
    implicit none
    integer, parameter :: MAX_SIZE = 45 !
    integer :: n, i
    real, dimension(MAX_SIZE) :: grades
    real :: total = 0, avg

    print *, "Enter number of student: "
    read *, n

    if(n > MAX_SIZE) then
        stop "Too many students!"
    elseif(n < 1) then
        stop "Too few students!"
    end if


    do i = 1, n
        write(*, *) "Enter grade: "
        read (*, *) grades(i)

        total = total + grades(i)
    end do

    avg = total / n

    print *, "Grades of good Students: "
    do i = 1, n
        if(grades(i) >= avg) print *, grades(i)
    end do


end
