made  grade average calculation into a function