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

  1.                          -- Chapter 8 - Programming exercixe 1
  2. -- Centigrade to Farenheit temperature table
  3. --
  4. --  This program generates a list of Centigrade and Farenheit
  5. --    temperatures with a note at the freezing point of water
  6. --    and another note at the boiling point of water.
  7.  
  8. with Text_IO;
  9. use Text_IO;
  10.  
  11. procedure CH08_1 is
  12.  
  13.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  14.    use Int_IO;
  15.  
  16.    Centigrade, Farenheit : INTEGER;
  17.  
  18.    procedure Cent_To_Faren(Cent  : in     INTEGER;
  19.                            Faren :    out INTEGER) is
  20.    begin
  21.       Faren := 32 + Cent * 9 / 5;
  22.    end Cent_To_Faren;
  23.  
  24. begin
  25.    Put("Centigrade to Farenheit temperature table");
  26.    New_Line(2);
  27.    for Count in INTEGER range -2..12 loop
  28.       Centigrade := 10 * Count;
  29.       Cent_To_Faren(Centigrade,Farenheit);
  30.       Put("C =");
  31.       Put(Centigrade,5);
  32.       Put("    F =");
  33.       Put(Farenheit,5);
  34.       if Centigrade = 0 then
  35.          Put("  Freezing point of water");
  36.       end if;
  37.       if Centigrade = 100 then
  38.          Put("  Boiling point of water");
  39.       end if;
  40.       New_Line;
  41.    end loop;
  42. end CH08_1;
  43.  
  44.  
  45.  
  46.  
  47. -- Result of execution
  48.  
  49. -- Centigrade to Farenheit temperature table
  50. --
  51. -- C =  -20    F =   -4
  52. -- C =  -10    F =   14
  53. -- C =    0    F =   32  Freezing point of water
  54. -- C =   10    F =   50
  55. -- C =   20    F =   68
  56. -- C =   30    F =   86
  57. -- C =   40    F =  104
  58. -- C =   50    F =  122
  59. -- C =   60    F =  140
  60. -- C =   70    F =  158
  61. -- C =   80    F =  176
  62. -- C =   90    F =  194
  63. -- C =  100    F =  212  Boiling point of water
  64. -- C =  110    F =  230
  65. -- C =  120    F =  248
  66.  
  67.