home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / programm / programi / adaed.lzh / Ada / Examples / UFO.ada < prev    next >
Encoding:
Text File  |  1992-03-03  |  5.0 KB  |  213 lines

  1. --From schweige@taurus.cs.nps.navy.mil Sun Mar  1 21:16:15 1992
  2. --Return-Path: <schweige@taurus.cs.nps.navy.mil>
  3. --Received: from taurus.cs.nps.navy.mil (taurus-campus.cs.nps.navy.mil) by beno.CSS.GOV (4.1/SMI-4.1)
  4. --        id AA18224; Sun, 1 Mar 92 21:16:13 EST
  5. --Received: from aldebaran.cs.nps.navy.mil.nps.navy.mil by taurus.cs.nps.navy.mil (4.1/cs.nps-1.0)
  6. --        id AA12312; Sun, 1 Mar 92 18:15:44 PST
  7. --Date: Sun, 1 Mar 92 18:15:44 PST
  8. --From: schweige@taurus.cs.nps.navy.mil (Jeffrey M. Schweiger)
  9. --Message-Id: <9203020215.AA12312@taurus.cs.nps.navy.mil>
  10. --To: black@beno.CSS.GOV
  11. --Subject: Again, more Ada
  12. --Status: R
  13.  
  14. -- Title          : Project 2
  15. -- Author         : Jeffrey M. Schweiger
  16. -- Date           : 20 Apr 1989
  17. -- Revised        : 20 Apr 1989
  18. -- Course         : CS-2970
  19. -- System         : Zenith 248
  20. -- Compiler       : InterAda
  21. -- Description    : Given a input file with data of UFO sightings during one
  22. --                  twenty-four hour period, consisting of time of day of the
  23. --                  sighting, and estimated altitude of the sighting, output
  24. --                  list of all sightings, and highlight data on the first,
  25. --                  minimum altitude, and last sighting of the day.
  26.  
  27. with TEXT_IO;
  28. use TEXT_IO;
  29.  
  30. procedure UNIDENTIFIED_FLYING_OBJECTS is
  31.  
  32.   FILE_NAME       : constant STRING := "UFO.DAT";
  33.   THE_FILE        : FILE_TYPE;
  34.  
  35.   HOURS_FIRST,
  36.   MINUTES_FIRST,
  37.   SECONDS_FIRST,
  38.   ALTITUDE_FIRST  : INTEGER;
  39.   -- Data for first sighting of the day
  40.  
  41.   HOURS_MIN,
  42.   MINUTES_MIN,
  43.   SECONDS_MIN,
  44.   ALTITUDE_MIN    : INTEGER;
  45.   -- Data for sighting with closest point to the earth for the day
  46.  
  47.   HOURS_LAST,
  48.   MINUTES_LAST,
  49.   SECONDS_LAST,
  50.   ALTITUDE_LAST   : INTEGER;
  51.   -- Data for last sighting of the day
  52.  
  53.   -- Input and output procedures for INTEGERS
  54.   package INTEGER_INOUT is new INTEGER_IO(INTEGER);
  55.   use INTEGER_INOUT;
  56.  
  57.  
  58.   -- Create procedure to print leading zeros for time output
  59.  
  60.   procedure PUT_TIME(TIME  : INTEGER) is
  61.     begin
  62.       if TIME < 10 then
  63.         PUT("0");
  64.         PUT(TIME, WIDTH => 1);
  65.       else
  66.         PUT(TIME, WIDTH => 2);
  67.       end if;
  68.     end PUT_TIME;
  69.  
  70.  
  71.  
  72. begin
  73.  
  74.   -- print header information
  75.   SET_COL(13);
  76.   PUT("Daily Unidentified Flying Object (UFO) Sighting Report");
  77.   NEW_LINE(3);
  78.   PUT ("Time of Sighting");
  79.   SET_COL(27);
  80.   PUT_LINE("Altitude");
  81.  
  82.  
  83.   -- open file for input and read first observation
  84.  
  85.   OPEN(THE_FILE, MODE => IN_FILE, NAME => FILE_NAME);
  86.  
  87.   GET(THE_FILE, HOURS_FIRST);
  88.   GET(THE_FILE, MINUTES_FIRST);
  89.   GET(THE_FILE, SECONDS_FIRST);
  90.   GET(THE_FILE, ALTITUDE_FIRST);
  91.   SKIP_LINE(THE_FILE);
  92.  
  93.   -- Write first observation of the day
  94.  
  95.   SET_COL(4);
  96.   PUT_TIME(HOURS_FIRST);
  97.   PUT(":");
  98.   PUT_TIME(MINUTES_FIRST);
  99.   PUT(":");
  100.   PUT_TIME(SECONDS_FIRST);
  101.  
  102.   SET_COL(25);  -- move to altitude column
  103.  
  104.   PUT(ALTITUDE_FIRST, WIDTH => 4);
  105.   PUT_LINE(" meters.");
  106.  
  107.  
  108.   -- assign first observation data as initial minimum sighting data
  109.  
  110.   HOURS_MIN := HOURS_FIRST;
  111.   MINUTES_MIN := MINUTES_FIRST;
  112.   SECONDS_MIN := SECONDS_FIRST;
  113.   ALTITUDE_MIN := ALTITUDE_FIRST;
  114.  
  115.  
  116.   -- assign first observation data as initial last sighting data
  117.  
  118.   HOURS_LAST := HOURS_FIRST;
  119.   MINUTES_LAST := MINUTES_FIRST;
  120.   SECONDS_LAST := SECONDS_FIRST;
  121.   ALTITUDE_LAST := ALTITUDE_FIRST;
  122.  
  123.  
  124.   -- Read data file until end of file
  125.  
  126.   while not END_OF_FILE(THE_FILE) loop
  127.  
  128.     -- Read from the disk file, current observation is last observation
  129.  
  130.     GET(THE_FILE, HOURS_LAST);
  131.     GET(THE_FILE, MINUTES_LAST);
  132.     GET(THE_FILE, SECONDS_LAST);
  133.     GET(THE_FILE, ALTITUDE_LAST);
  134.  
  135.     SKIP_LINE(THE_FILE);
  136.  
  137.  
  138.     -- Write current observation to screen
  139.  
  140.     SET_COL(4);
  141.     PUT_TIME(HOURS_LAST);
  142.     PUT(":");
  143.     PUT_TIME(MINUTES_LAST);
  144.     PUT(":");
  145.     PUT_TIME(SECONDS_LAST);
  146.     SET_COL(25);
  147.     PUT(ALTITUDE_LAST, WIDTH => 4);
  148.     PUT_LINE(" meters.");
  149.  
  150.  
  151.     -- If current observation altitude is less than previous minimum
  152.     -- altitude, assign new minimum
  153.  
  154.     if ALTITUDE_LAST < ALTITUDE_MIN then
  155.  
  156.       HOURS_MIN := HOURS_LAST;
  157.       MINUTES_MIN := MINUTES_LAST;
  158.       SECONDS_MIN := SECONDS_LAST;
  159.       ALTITUDE_MIN := ALTITUDE_LAST;
  160.  
  161.     end if;
  162.  
  163.   -- end data read loop
  164.  
  165.   end loop;
  166.  
  167.   CLOSE(THE_FILE);
  168.  
  169.  
  170.   -- Write time and altitude of first sighting of the day
  171.  
  172.   NEW_LINE(2);
  173.   PUT("The first sighting of the day was at ");
  174.   PUT_TIME(HOURS_FIRST);
  175.   PUT(":");
  176.   PUT_TIME(MINUTES_FIRST);
  177.   PUT(":");
  178.   PUT_TIME(SECONDS_FIRST);
  179.   PUT(".  Altitude was ");
  180.   PUT(ALTITUDE_FIRST, WIDTH => 4);
  181.   PUT_LINE(" meters.");
  182.   NEW_LINE(2);
  183.  
  184.  
  185.   -- Write time minimum altitude was first observed and the altitude
  186.  
  187.   PUT("Minimum altitude was first observed at ");
  188.   PUT_TIME(HOURS_MIN);
  189.   PUT(":");
  190.   PUT_TIME(MINUTES_MIN);
  191.   PUT(":");
  192.   PUT_TIME(SECONDS_MIN);
  193.   PUT(".  Minimum altitude was ");
  194.   PUT(ALTITUDE_MIN, WIDTH => 4);
  195.   PUT_LINE(" meters.");
  196.   NEW_LINE(2);
  197.  
  198.  
  199.   -- Write time and altitude of last sighting of the day
  200.  
  201.   PUT("The last sighting of the day was at ");
  202.   PUT_TIME(HOURS_LAST);
  203.   PUT(":");
  204.   PUT_TIME(MINUTES_LAST);
  205.   PUT(":");
  206.   PUT_TIME(SECONDS_LAST);
  207.   PUT(".  Altitude was ");
  208.   PUT(ALTITUDE_LAST, WIDTH => 4);
  209.   PUT_LINE(" meters.");
  210.  
  211.  
  212. end UNIDENTIFIED_FLYING_OBJECTS;
  213.