fork download
  1. PROGRAM Radioactive_Decay
  2. ! written by Ryan Hancock in 2012
  3. !----------------------------------------------------------------------------
  4. ! This program calculates the amount of a radioactive substance that
  5. ! remains after a specified time, given an initial amount and its
  6. ! half-life. Variables used are:
  7. ! InitalAmount : initial amount of substance (mg)
  8. ! HalfLife : half-life of substance (days)
  9. ! Time : time at which the amount remaining is calculated (days)
  10. ! AmountRemaining : amount of substance remaining (mg)
  11. !
  12. ! Input: InitialAmount, HalfLife, Time
  13. ! Output: AmountRemaining
  14. !-----------------------------------------------------------------------------
  15.  
  16. IMPLICIT NONE
  17. REAL :: InitialAmount, HalfLife, Time, AmountRemaining
  18.  
  19. ! Get values for InitialAmount, HalfLife, and Time.
  20.  
  21. WRITE(*,*) "Enter initial amount (mg) of substance, its half-life (days)"
  22. WRITE(*,*) "and time (days) at which to find amount remaining:"
  23. READ *, InitialAmount, HalfLife, Time
  24.  
  25. ! Compute the amount remaining at the specified time.
  26. AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife)
  27.  
  28. ! Display AmountRemaining.
  29. WRITE(*,*) "Amount remaining =", AmountRemaining, "mg"
  30.  
  31. END PROGRAM Radioactive_Decay
  32.  
Success #stdin #stdout 0.01s 2620KB
stdin
10
140
140
stdout
 Enter initial amount (mg) of substance, its half-life (days)
 and time (days) at which to find amount remaining:
 Amount remaining =   5.0000000     mg