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

stdout
 Enter initial amount (mg) of substance, its half-life (days)
 and time (days) at which to find amount remaining:
 Amount remaining =  0.35355338     mg