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