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

  1.                               -- Chapter 21 - Programming exercise 3
  2. package Stuff is
  3.  
  4.    type MONTH_NAMES is (JAN, FEB, MAR, APR, MAY, JUN,
  5.                                       JUL, AUG, SEP, OCT, NOV, DEC);
  6.    type DATE is
  7.       record
  8.          Month : MONTH_NAMES;
  9.          Day   : INTEGER range 1..31;
  10.          Year  : INTEGER range 1800..2100;
  11.       end record;
  12.  
  13.    Pi     : constant := 3.14159;
  14.    Two_Pi : constant := 2 * Pi;
  15.  
  16. end Stuff;
  17.  
  18.  
  19.  
  20. with Text_IO, Stuff;
  21. use Text_IO, Stuff;
  22.  
  23. procedure CH21_3 is
  24.  
  25. package Flt_IO is new Text_IO.Float_IO(FLOAT);
  26. use Flt_IO;
  27. package Int_IO is new Text_IO.Integer_IO(INTEGER);
  28. use Int_IO;
  29. package Enum_IO is new Text_IO.Enumeration_IO(MONTH_NAMES);
  30. use Enum_IO;
  31.  
  32. Birth_Day : DATE := (OCT, 18, 1938);
  33.  
  34. begin
  35.    Put("My birthday is ");
  36.    Put(Birth_Day.Month);
  37.    Put(Birth_Day.Day,3);
  38.    Put(",");
  39.    Put(Birth_Day.Year,5);
  40.    New_Line(2);
  41.  
  42.    Put("The value of Pi is");
  43.    Put(Pi,3,6,0);
  44.    New_Line;
  45. end CH21_3;
  46.  
  47.  
  48.  
  49.  
  50. -- Result of execution
  51.  
  52. -- My birthday is OCT 18, 1938
  53. --
  54. -- The value of Pi is  3.141590
  55.  
  56.  
  57.