PROGRAM trebuchet ! Filename: trebuchet.f90 ! ! Programmer: Br. David Carlson ! ! Date: January 26, 2006 ! ! This program performs some calculations related to the performance of a ! trebuchet. The user is asked to input the angle of elevation (in degrees) ! for the rock that is thrown by the trebuchet. The starting velocity is ! assumed to always be 127 miles per hour. The program calculates and outputs ! the number of seconds that the rock is in the air as well as the horizontal ! distance travelled by the rock (in yards). Air resistance is ignored. ! Constants: REAL, PARAMETER::INITIAL_VELOCITY = 127.0 ! Initial velocity of rock (miles per hour). REAL, PARAMETER::MINUTES_PER_HOUR = 60.0 ! Minutes per hour. REAL, PARAMETER::SECONDS_PER_MIN = 60.0 ! Seconds per minute. REAL, PARAMETER::FEET_PER_MILE = 5280.0 ! Number of feet in a mile. REAL, PARAMETER::FEET_PER_YARD = 3.0 ! Number of feet in a yard. ! Variables: REAL::InitialFeetPerSec ! Initial velocity in feet per second. REAL::InitialVertVelocity ! Initial vertical component of velocity in feet per second. REAL::InitialHorizVelocity ! Initial horizontal component of velocity in feet per second. REAL::Time ! Time the rock is in air in seconds. REAL::HorizDistanceFt ! Horizontal distance rock is thrown in feet. REAL::HorizDistanceYd ! Horizontal distance rock is thrown in yards. REAL::AngleDegrees ! Angle of elevation in degrees. REAL::AngleRadians ! Angle of elevation in radians. REAL::Pi ! PI REAL::RadiansPerDegree ! Radians per degree to convert from degrees to radians. WRITE (*,*) 'Enter the angle of elevation for the rock that is thrown by the trebuchet:' READ (*,*) AngleDegrees WRITE (*,*) 'Assuming an initial velocity of ', INITIAL_VELOCITY, ' miles per hour.' Pi = 2.0 * ASIN(1.0) RadiansPerDegree = Pi / 180.0 InitialFeetPerSec = INITIAL_VELOCITY * FEET_PER_MILE / (MINUTES_PER_HOUR * SECONDS_PER_MIN) AngleRadians = AngleDegrees * RadiansPerDegree InitialVertVelocity = InitialFeetPerSec * SIN(AngleRadians) InitialHorizVelocity = InitialFeetPerSec * COS(AngleRadians) Time = InitialVertVelocity / 16.0 HorizDistanceFt = InitialHorizVelocity * Time HorizDistanceYd = HorizDistanceFt / FEET_PER_YARD WRITE (*,*) 'The rock is in the air for about ', Time, ' seconds.' WRITE (*,*) 'The rock travels horizontally about ', HorizDistanceYd, ' yards.' END PROGRAM