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

  1.                               -- Chapter 13 - Programming exercise 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Ch13_1 is
  6.  
  7.    package Real_IO is new Text_IO.Float_IO(FLOAT);
  8.    use Real_IO;
  9.  
  10.    type BOX_TYPE is
  11.       record
  12.          Length : FLOAT;
  13.          Width  : FLOAT;
  14.          Height : FLOAT;
  15.       end record;
  16.  
  17.    type POINT_TO_BOX is access BOX_TYPE;
  18.  
  19.    Small, Medium, Large : POINT_TO_BOX;
  20.  
  21. begin
  22.  
  23.    Small  := new BOX_TYPE;
  24.    Medium := new BOX_TYPE;
  25.    Large  := new BOX_TYPE;
  26.  
  27.    Small.Length := 3.5;
  28.    Small.Width  := 2.4;
  29.    Small.Height := 1.9;
  30.    Medium.Length := 7.4;
  31.    Medium.Width  := 6.4;
  32.    Medium.Height := 9.3;
  33.    Large.Length := 13.8;
  34.    Large.Width  := 21.5;
  35.    Large.Height := 15.1;
  36.  
  37.    Put(Small.Length,8,3,0);
  38.    Put(Small.Width,8,3,0);
  39.    Put(Small.Height,8,3,0);
  40.    Put(Small.Length * Small.Width * Small.Height,8,3,0);
  41.    New_Line;
  42.  
  43.    Put(Medium.Length,8,3,0);
  44.    Put(Medium.Width,8,3,0);
  45.    Put(Medium.Height,8,3,0);
  46.    Put(Medium.Length * Medium.Width * Medium.Height,8,3,0);
  47.    New_Line;
  48.  
  49.    Put(Large.Length,8,3,0);
  50.    Put(Large.Width,8,3,0);
  51.    Put(Large.Height,8,3,0);
  52.    Put(Large.Length * Large.Width * Large.Height,8,3,0);
  53.    New_Line;
  54.  
  55. end Ch13_1;
  56.  
  57.  
  58.  
  59.  
  60. -- Result of execution
  61.  
  62. --        3.500       2.400       1.900      15.960
  63. --        7.400       6.400       9.300     440.448
  64. --       13.800      21.500      15.100    4480.170
  65.