-- hw5.adb -- This is the main procedure you are to use for homework 5 -- You will have to augment UNITS with more types and subtypes -- You will have to augment UNITS_OUTPUT for ACCELERATION_MKS -- You will have to augment MKS_PHYSICS_1 with more operators and -- functions. -- This procedure solves a few physics problems involving -- time, distance, vecocity and acceleration. All units are -- in the MKS system of units. Note that all "put" calls -- on physical quantities are to be printed as the value followed -- by the unit. -- -- make available types for physical units with UNITS ; use UNITS ; -- make available operations on MKS types with MKS_PHYSICS_1 ; use MKS_PHYSICS_1 ; -- make PUT available for physical units types with UNITS_OUTPUT ; use UNITS_OUTPUT ; with Ada.Text_IO ; use Ada.Text_IO ; with Ada.Numerics.Long_Elementary_Functions; use Ada.Numerics.Long_Elementary_Functions; procedure Hw5 is G : ACCELERATION_MKS := MAKE_TYPE ( 9.80665 ) ; FALL : DISTANCE_METER ; FALL_TIME : TIME_SECOND ; V_FINAL : VELOCITY_METER_PER_SECOND ; begin Put_Line(" Hw5 running."); PUT ( " Test printout and value of acceleration, " ) ; PUT ( G ) ; PUT_LINE ( " = G " ) ; -- How far will Ball_1 fall in 1.5 second in earths gravity ? FALL := 0.5 * G * TIME_SECOND'( MAKE_TYPE ( 1.5 ) ) ** 2 ; PUT ( FALL ) ; NEW_LINE ; -- Cross check that the time for the ball to fall is 1.5 seconds. FALL_TIME := SQRT ( 2.0 * FALL / G ) ; PUT ( FALL_TIME ) ; NEW_LINE ; -- Now determine the final velocity if the ball falls another FALL meters -- Method : square root of initial velocity squared plus twice -- the acceleration times the distance V_FINAL := SQRT (( G * FALL_TIME ) ** 2 + 2.0 * G * FALL) ; PUT ( V_FINAL ) ; NEW_LINE ; end hw5 ;