fork download
  1. Program TankSize
  2. !-----------------------------------------------------------------------------------------------
  3. !Tyler Martin Engr 225 Lab 2 Extra Credit 25 January 2012
  4. ! Tank Size Optimization
  5. !
  6. !Assumptions: That the oil will fill up the tank completely, and that the corners of the tank
  7. ! will be perfectly square and not rounded.
  8. !
  9. !-----------------------------------------------------------------------------------------------
  10.  
  11. Implicit None
  12. integer, parameter::dp=selected_real_kind(15)
  13. real(dp) :: radius, cylheight, coneheight, totalvol, conevol, cylvol, conearea, cylarea, totalcost, pi
  14.  
  15. pi = 3.1415959
  16. totalvol = 500.0
  17.  
  18. write (*,*) "Please enter a radius."
  19. read (*,*) radius
  20.  
  21. conevol = (pi*radius**3.0)/3.0
  22. coneheight = radius
  23. cylheight = (totalvol - conevol)/(pi*radius**2.0)
  24.  
  25. write (*,*) "The height of the cone will be ", coneheight
  26. write (*,*) "The height of the cylinder will be ", cylheight
  27.  
  28. cylarea = 2.0*pi*radius*cylheight + pi*radius**2.0
  29. conearea = pi*radius*sqrt(2.0*radius**2.0)
  30. totalcost = (cylarea*300.0) + (conearea*400.0)
  31.  
  32. write (*,*) "The total cost of the project in dollars will be ", totalcost
  33.  
  34. stop
  35. end program tanksize
Success #stdin #stdout 0.01s 2620KB
stdin
3.3
stdout
 Please enter a radius.
 The height of the cone will be    3.2999999999999998     
 The height of the cylinder will be    13.514764154603050     
 The total cost of the project in dollars will be    113683.50649004897