home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / piwg / z000018.ada < prev    next >
Encoding:
Text File  |  1988-05-03  |  2.0 KB  |  58 lines

  1.  
  2. -- This procedure solves a few physics problems involving
  3. -- time, distance, vecocity and acceleration. All units are 
  4. -- in the MKS system of units. Note that all "put" calls
  5. -- on physical quantities are to be printed as the value followed
  6. -- by the unit.
  7. --
  8. -- make available types for physical units
  9. with PHYSICAL_UNITS_BASIC ; use PHYSICAL_UNITS_BASIC ;
  10. with PHYSICAL_UNITS_MECHANICAL ; use PHYSICAL_UNITS_MECHANICAL ;
  11. with PHYSICAL_UNITS_ELECTRICAL ; use PHYSICAL_UNITS_ELECTRICAL ;
  12. with PHYSICAL_UNITS_OTHER ; use PHYSICAL_UNITS_OTHER ;
  13.  
  14. -- make available operations on MKS types
  15. with MKS_PHYSICS_MECHANICAL ; use MKS_PHYSICS_MECHANICAL ;
  16. with MKS_PHYSICS_ELECTRICAL ; use MKS_PHYSICS_ELECTRICAL ;
  17.  
  18. -- make available units conversion constants
  19. with PHYSICAL_CONVERSION_CONSTANT ; use PHYSICAL_CONVERSION_CONSTANT ;
  20.  
  21. -- make PUT available for physical units types
  22. with PHYSICAL_UNITS_OUTPUT_BASIC ; use PHYSICAL_UNITS_OUTPUT_BASIC ;
  23. with PHYSICAL_UNITS_OUTPUT_MECHANICAL ; use PHYSICAL_UNITS_OUTPUT_MECHANICAL ;
  24. with PHYSICAL_UNITS_OUTPUT_ELECTRICAL ; use PHYSICAL_UNITS_OUTPUT_ELECTRICAL ;
  25.  
  26. --
  27. with TEXT_IO ; use TEXT_IO ;
  28.  
  29. procedure Z000018 is
  30.  
  31. --    define acceleration due to gravity
  32.   G : ACCELERATION_MKS := DIMENSION ( 9.80665 ) ;
  33.   FALL : DISTANCE_METER ;
  34.   FALL_TIME : TIME_SECOND ;
  35.   V_FINAL : VELOCITY_METER_PER_SECOND ;
  36. begin
  37.   PUT ( " Test printout and value of acceleration, " ) ;
  38.   PUT ( G ) ;
  39.   PUT_LINE ( " = G " ) ;
  40.  
  41. -- How far will Ball_1 fall in 1.5 second in earths gravity ?
  42.   FALL := 0.5 * G * TIME_SECOND' ( DIMENSION( 1.5 )) ** 2 ;
  43.   PUT ( FALL ) ;
  44.   NEW_LINE ;
  45.  
  46. -- Cross check that the time for the ball to fall is 1.5 seconds.
  47.   FALL_TIME := SQRT ( 2.0 * FALL / G ) ;
  48.   PUT ( FALL_TIME ) ;
  49.   NEW_LINE ;
  50.  
  51. -- Now determine the final velocity if the ball falls another 0.2 meter
  52. -- Method :  square root of initial velocity squared plus twice
  53. --           the acceleration times the distance
  54.   V_FINAL := SQRT (( G * FALL_TIME ) ** 2 + 2.0 * G * FALL) ;
  55.   PUT ( V_FINAL ) ;
  56.   NEW_LINE ;
  57. end Z000018 ;
  58.