program game
implicit none
integer
:: m, i, total_roll_number, point_number, flag
real
:: y
integer, allocatable :: Num(:), seed(:)
write (*,*) 'Please input any two integer numbers'
read (*,*) Seed(1), Seed(2)
Call Random_Seed (Size = m)
Call Random_Seed (Put = Seed (1 : m))
do i = 1:2
Call Random_Number (y)
Num(i) = mod(int(100*y) , 6) + 1
end
total_roll_number = Num(1) + Num(2)
select case(total_roll_number)
case(7, 11)
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
write(*,*)"Player wins"
case(2, 3, 12)
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
write(*,*)"Player loses"
case(4, 5, 6, 8, 9, 10)
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
write(*,"( 'Point is ',I3)") total_roll_number
flag = 1
point_number = total_roll_number
do while ( flag = 1 )
do i = 1: 2
Call Random_Number (y)
Num(i) = mod(int(100*y) , 6) + 1
end
total_roll_number = Num(1) + Num(2)
if ( total_roll_number == point_number )
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
write(*,*) "Player wins"
flag = 0
else if( total_roll_number == 7 )
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
write(*,*) "Player loses"
flag = 0
else
write(*,"('Player rolled',I2,1X,'+',I2,1X,'=',I3)") &
Num(1), Num(2), total_roll_number
end
end
end
end program