language: Fortran (gfortran-4.3.4)
date: 125 days 14 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
PROGRAM Radioactive_Decay
!----------------------------------------------------------------------------
! This program calculates the amount of a radioactive substance that 
! remains after a specified time, given an initial amount and its 
! half-life.  Variables used are:
!   InitalAmount    : initial amount of substance (mg)
!   HalfLife        : half-life of substance (days)
!   Time            : time at which the amount remaining is calculated (days)
!   AmountRemaining : amount of substance remaining (mg)
!
! Input:   InitialAmount, HalfLife, Time
! Output:  AmountRemaining
!-----------------------------------------------------------------------------
 
  IMPLICIT NONE
  REAL :: InitialAmount, HalfLife, Time, AmountRemaining
 
  ! Get values for InitialAmount, HalfLife, and Time.
 
  write(*,*) "Enter initial amount (mg) of substance, its half-life (days)"
  write (*,*) "and time (days) at which to find amount remaining:"
  READ *, InitialAmount, HalfLife, Time
 
  ! Compute the amount remaining at the specified time.
  AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife)
 
  ! Display AmountRemaining.
  PRINT *, "Amount remaining =", AmountRemaining, "mg"
 
END PROGRAM Radioactive_Decay
 
look for extra credit