-- Chapter 15 - Programming example 2 with Ada.Text_IO; procedure CH15_2 is type MY_FIXED is delta 0.01 range 20.0..42.0; type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN); type MY_INTEGER is range -13..323; X_Value : FLOAT := 3.14; Index : INTEGER := 27; Count : MY_INTEGER; What : BOOLEAN := TRUE; Who : BOOLEAN := FALSE; Size : MY_FIXED := 24.33; Today : DAY := TUE; package Int_IO is new Ada.Text_IO.Integer_IO(INTEGER); package Flt_IO is new Ada.Text_IO.Float_IO(FLOAT); package Enum_IO is new Ada.Text_IO.Enumeration_IO(BOOLEAN); package Fix_IO is new Ada.Text_IO.Fixed_IO(MY_FIXED); package Day_IO is new Ada.Text_IO.Enumeration_IO(DAY); package New_Int_IO is new Ada.Text_IO.Integer_IO(MY_INTEGER); begin -- INTEGER outputs Ada.Text_IO.Put("Index is --->"); Int_IO.Put(Index); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Index is --->"); Int_IO.Put(Index,3); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Index is --->"); Int_IO.Put(Index,8); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line(2); -- FLOAT outputs Ada.Text_IO.Put("Put(X_Value) -------->"); Flt_IO.Put(X_Value); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(X_Value,5) ------>"); Flt_IO.Put(X_Value,5); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(X_Value,5,5) ---->"); Flt_IO.Put(X_Value,5,5); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(X_Value,5,5,0) -->"); Flt_IO.Put(X_Value,5,5,0); Ada.Text_IO.New_Line(2); -- MY_FIXED outputs Ada.Text_IO.Put("Put(Size) -------->"); Fix_IO.Put(Size); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(Size,5) ------>"); Fix_IO.Put(Size,5); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(Size,5,5) ---->"); Fix_IO.Put(Size,5,5); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Put(Size,5,5,0) -->"); Fix_IO.Put(Size,5,5,0); Ada.Text_IO.New_Line(2); -- BOOLEAN outputs Ada.Text_IO.Put("What is ---->"); Enum_IO.Put(What); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Who is ----->"); Enum_IO.Put(Who); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("What is ---->"); Enum_IO.Put(What,7); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Who is ----->"); Enum_IO.Put(Who,8); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("TRUE is ---->"); Enum_IO.Put(TRUE); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("FALSE is --->"); Enum_IO.Put(FALSE); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line(2); -- Enumeration outputs Ada.Text_IO.Put("Today is --->"); Day_IO.Put(Today); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Today is --->"); Day_IO.Put(Today,6); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("Today is --->"); Day_IO.Put(Today,7); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("WED is ----->"); Day_IO.Put(WED); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line; Ada.Text_IO.Put("WED is ----->"); Day_IO.Put(WED,5); Ada.Text_IO.Put("<---"); Ada.Text_IO.New_Line(2); end CH15_2; -- Result of execution -- Index is ---> 27<--- -- Index is ---> 27<--- -- Index is ---> 27<--- -- -- Put(X_Value) --------> 3.14000000000000E+00 -- Put(X_Value,5) ------> 3.14000000000000E+00 -- Put(X_Value,5,5) ----> 3.14000E+00 -- Put(X_Value,5,5,0) --> 3.14000 -- -- Put(Size) --------> 24.33 -- Put(Size,5) ------> 24.33 -- Put(Size,5,5) ----> 24.32813 -- Put(Size,5,5,0) --> 24.32813 -- -- What is ---->TRUE<--- -- Who is ----->FALSE<--- -- What is ---->TRUE <--- -- Who is ----->FALSE <--- -- TRUE is ---->TRUE<--- -- FALSE is --->FALSE<--- -- -- Today is --->TUE<--- -- Today is --->TUE <--- -- Today is --->TUE <--- -- WED is ----->WED<--- -- WED is ----->WED <---