fork download
  1. !George Austin Corbett, ENGR225, Thursday 1700-2000 lab.
  2. !Note this is NOT my code, but was pasted in from figure 1.8 of chapter 1 of Fortran 90 book
  3.  
  4. PROGRAM Radioactive_Decay
  5. !----------------------------------------------------------------------------
  6. ! This program calculates the amount of a radioactive substance that
  7. ! remains after a specified time, given an initial amount and its
  8. ! half-life. Variables used are:
  9. ! InitalAmount : initial amount of substance (mg)
  10. ! HalfLife : half-life of substance (days)
  11. ! Time : time at which the amount remaining is calculated (days)
  12. ! AmountRemaining : amount of substance remaining (mg)
  13. !
  14. ! Input: InitialAmount, HalfLife, Time
  15. ! Output: AmountRemaining
  16. !-----------------------------------------------------------------------------
  17.  
  18. IMPLICIT NONE
  19. REAL :: InitialAmount, HalfLife, Time, AmountRemaining
  20.  
  21. ! Get values for InitialAmount, HalfLife, and Time.
  22.  
  23. WRITE(*,*) "Enter initial amount (mg) of substance, its half-life (days)"
  24. WRITE(*,*) "and time (days) at which to find amount remaining:"
  25. READ *, InitialAmount, HalfLife, Time
  26.  
  27. ! Compute the amount remaining at the specified time.
  28. AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife)
  29.  
  30. ! Display AmountRemaining.
  31. PRINT *, "Amount remaining =", AmountRemaining, "mg"
  32.  
  33. END PROGRAM Radioactive_Decay
  34.  
Success #stdin #stdout 0.01s 2620KB
stdin
1 1 1
stdout
 Enter initial amount (mg) of substance, its half-life (days)
 and time (days) at which to find amount remaining:
 Amount remaining =  0.50000000     mg