The Ada Program: ski_wax.adb

  1 -- ski_wax.adb: determine best ski wax given snow conditions

  2 
  3 with Ada.Text_IO, Ada.Integer_Text_IO;
  4 use Ada;
  5 
  6 procedure Ski_Wax is
  7 
  8    type Snow_Type is (Powdered, Packed, Crusty);
  9    type Color_Type is  (White, Green, Blue, Violet, Red, Yellow);
 10    type Variety_Type is (Special, Standard, Extra);
 11 
 12    package Snow_IO is new Text_IO.Enumeration_IO (Enum=>Snow_Type);
 13    package Color_IO is new Text_IO.Enumeration_IO (Enum=>Color_Type);
 14    package Variety_IO is new Text_IO.Enumeration_IO (Enum=>Variety_Type);
 15 
 16    Temperature    : Integer;         -- The current outside temperature

 17    Snow_Condition : Snow_Type;       -- The condition of the snow

 18    Wax_Color      : Color_Type;      -- The wax group selected

 19    Wax_Variety    : Variety_Type;    -- The wax variety selected

 20 
 21 begin
 22 
 23    -- Obtain Temperature

 24    Text_IO.Put ("Enter the outside temperature: ");
 25    Integer_Text_IO.Get (Temperature);
 26 
 27    -- Obtain Snow Condition

 28    Text_IO.Put ("Enter the snow condition (Powdered, Packed, Crusty): ");
 29    Snow_IO.Get (Snow_Condition);
 30 
 31    -- Echo print

 32    Text_IO.New_Line;
 33    Text_IO.Put ("The current temperature is ");
 34    Integer_Text_IO.Put (Item=>Temperature, Width=>0);
 35    Text_IO.New_Line;
 36    Text_IO.Put ("The snow is ");
 37    Snow_IO.Put (Item=>Snow_Condition, Set=>Text_IO.Lower_Case);
 38    Text_IO.New_Line;
 39 
 40    -- Determine Wax Color

 41    if Temperature > 38 then
 42       Wax_Color := Yellow;
 43    elsif Temperature > 31 then
 44       Wax_Color := Red;
 45    elsif Temperature > 26 then
 46       Wax_Color := Violet;
 47    elsif Temperature > 18 then
 48       Wax_Color := Blue;
 49    elsif Temperature > 5 then
 50       Wax_Color := Green;
 51    else
 52       Wax_Color := White;
 53    end if;
 54 
 55    -- Determine Wax Variety (White and Yellow only come in Standard)

 56    if (Wax_Color=White) or else (Wax_Color=Yellow) then
 57       Wax_Variety := Standard;
 58    else
 59       if Snow_Condition = Powdered then
 60          Wax_Variety := Special;
 61       elsif Snow_Condition = Packed then
 62          Wax_Variety := Standard;
 63       else
 64          Wax_Variety := Extra;
 65       end if;
 66    end if;
 67 
 68    -- Output recommended ski wax

 69    Text_IO.New_Line;
 70    Text_IO.Put ("The recommended ski wax is ");
 71    Variety_IO.Put (Item=>Wax_Variety, Set=>Text_IO.Lower_Case);
 72    Text_IO.Put (" ");
 73    Color_IO.Put (Item=>Wax_Color, Set=>Text_IO.Lower_Case);
 74    Text_IO.New_Line;
 75 
 76 end Ski_Wax;