program tripos2
implicit none
integer :: code
real :: p1, p2, p3, maths
real :: av1, av2
! read in the marks
write(*,*) 'Enter marks for four IA subjects (maths last):'
read(*,*) p1, p2, p3, maths
! read in the type of maths
write(*,*) 'Enter type of maths: (1 = full, 2 = QB, 3 = EMB)'
read(*,*) code
! work out the two averages
av1 = p1 + p2 + p3
av2 = av1 + maths
av1 = av1 / 3.0 ; av2 = av2 / 4.0
! use an if statement
if (code == 1) then
write(*,*) 'Final average = ',av2
else if (code == 2) then
write(*,*) 'Final average = ',max(av1,av2)
else if (code == 3) then
write(*,*) 'Final average = ',av1
else
write(*,*) 'Unknown maths code'
end if
end program tripos2
Uni. Of Cambridge
Dep. Of Physics
Computational Physics
Self-study guide 2
Programming in Fortran 95
Thanks to Dr. Rachael Padman and Michaelmas for allowing the citation.
참고사이트 https://www.mrao.cam.ac.uk/~rachael/compphys/SelfStudyF95.pdf
#fortran #Dr._Rachael_Padman_and_Michaelmas #fortran_tutorial #vfun #NAG_Fortran #FTN95