fork download
  1. program rDecay
  2. ! Program to calculate the radioactive decay of a material.
  3. real :: amnt_N0, amnt_t, decayC, halfLife, time
  4.  
  5. ! Obtain input from the user
  6. write (*,*) 'What is the half life of the material (days)? '
  7. read (*,*) halfLife
  8. write (*,*) 'What is the time span (days)? '
  9. read (*,*) time
  10. write (*,*) 'How much of the material is needed (grams)? '
  11. read (*,*) amnt_t
  12.  
  13. ! Calculate the decay constant
  14. decayC = log(2.0) / halfLife
  15. ! Calculate the initial amount of the material
  16. amnt_N0 = amnt_t * exp(decayC * time)
  17.  
  18. write (*,100) 'To obtain ', amnt_t, ' grams at the end of ', time, ' days'
  19. 100 format(A,F5.2,A,F5.2,A)
  20. write (*,200) 'requires ', amnt_N0, ' grams of the material to start with.'
  21. 200 format(A,F7.2,A)
  22.  
  23. end program rDecay
Runtime error #stdin #stdout 0.02s 2620KB
stdin
Standard input is empty
stdout
 What is the half life of the material (days)?