s!Grade calculator program GradeCalc implicit none integer :: score !prototype function return length character*2 calc !user inputs score write (*,*) ' Enter score: ' read (*,*) score !show grade write (*,*) ' Your grade: ', calc(score) end program GradeCalc !converts from numerical to letter grade function calc(sco) result(gr) implicit none character(*) :: gr integer :: sco SELECT CASE (sco) CASE (90:100) gr= 'A' CASE (80:89) gr= 'B' CASE (70:79) gr= 'C' CASE (60:69) gr= 'D' CASE (0:59) gr= 'F' CASE DEFAULT write (*,*) ' ERROR: Invalid score ' gr= 'x' END SELECT end function calc
Comments
0 B
|👍
/👎
0 B
|👍
/👎