
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.63 KB | hits: 38 | expires: Never
! Kendall Lewis
! CS 335 - Final Exam - Problem 6
! 5-7-12
PROGRAM test
IMPLICIT NONE
INTEGER :: i
INTEGER :: th
DO i = 1, 100
th = throw_dice()
PRINT*, 'total throw = ', th
END DO
CONTAINS
INTEGER FUNCTION throw_dice()
IMPLICIT NONE
REAL :: r
INTEGER :: dice_total
INTEGER :: throw1, throw2
CALL RANDOM_NUMBER(r)
throw1 = 1 + NINT(r*5)
PRINT*, 'throw1 = ', throw1
CALL RANDOM_NUMBER(r)
throw2 = 1 + NINT(r*5)
PRINT*, 'throw2 = ', throw2
dice_total = throw1 + throw2
RETURN
END FUNCTION throw_dice
END PROGRAM test