home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / answers / ch12_2.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.2 KB  |  55 lines

  1.                                        -- Chapter 12 - Program 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure CH12_2 is
  6.  
  7.    type MONTH_NAME is (JAN,FEB,MAR,APR,MAY,JUN,JUL,
  8.                                              AUG,SEP,OCT,NOV,DEC);
  9.  
  10.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  11.    use Int_IO;
  12.    package Enum_IO is new Text_IO.Enumeration_IO(MONTH_NAME);
  13.    use Enum_IO;
  14.  
  15.    type DATE is
  16.       record
  17.          Month : MONTH_NAME;
  18.          Day   : INTEGER range 1..31;
  19.          Year  : INTEGER range 1776..2010;
  20.       end record;
  21.  
  22.    Independence_Day : DATE;
  23.    Birth_Day        : DATE;
  24.    Today,Pay_Day    : DATE := (MAY,25,1982);
  25.  
  26. begin
  27.    Independence_Day.Month := JUL;
  28.    Independence_Day.Day := 4;
  29.    Independence_Day.Year := 1776;
  30.  
  31.    Birth_Day := Independence_Day;
  32.  
  33.    Pay_Day.Day := 30;
  34.  
  35.    Put("Independence day was on ");
  36.    Put(Independence_Day.Month,2);
  37.    Put(Independence_Day.Day,2);
  38.    Put(",");
  39.    Put(Independence_Day.Year,5);
  40.    New_Line;
  41.  
  42.    Birth_Day := (Day => 19, Month => FEB, Year => 1937);
  43.    Today := (JUL,14,1952);
  44.    Pay_Day := (JUL, Year => 1954, Day => 17);
  45.  
  46. end CH12_2;
  47.  
  48.  
  49.  
  50.  
  51. -- Result of execution
  52.  
  53. -- Independence day was on  JUL 4, 1776
  54.  
  55.