with Ada.Text_IO; with Ada.Integer_Text_IO; procedure Triangle0 is Size : Integer; -- The number of rows in the triangle Line_Count : Integer; -- Loop control variable for displaying rows Num_Blanks : Integer; -- Number of leading blanks in a single row of the triangle Blank_Count : Integer; -- Loop control variable for displaying blanks Num_Signs : Integer; -- Number of dollar signs in a single row of the triangle Dollar_Count : Integer; -- Loop control variable for displaying dollar signs begin -- Get a valid size -- Each iteration, get and check one number Size_Loop : loop Ada.Text_IO.Put (Item => "Enter an even positive triangle size: "); Ada.Integer_Text_IO.Get (Item => Size); exit Size_Loop when Size > 0 and Size rem 2 = 0; Ada.Text_IO.Put (Item => "Size must be positive and even"); Ada.Text_IO.New_Line (Spacing => 2); end loop Size_Loop; Ada.Text_IO.New_Line (Spacing => 2); Line_Count := 1; -- Initialize loop control variable -- Display the triangle -- Each iteration, display one line Line_Loop : loop exit Line_Loop when Line_Count > Size; -- Display one line Num_Blanks := Size - Line_Count; Blank_Count := 1; -- Initialize loop control variable -- Display the leading blanks -- Each iteration, display one blank Blank_Loop : loop exit Blank_Loop when Blank_Count > Num_Blanks; Ada.Text_IO.Put (Item => " "); Blank_Count := Blank_Count + 1; -- Update loop control variable end loop Blank_Loop; Num_Signs := 2 * Line_Count - 1; Dollar_Count := 1; -- Initialize loop control variable -- Display the dollar signs -- Each iteration, display one dollar sign Dollar_Loop : loop exit Dollar_Loop when Dollar_Count > Num_Signs; Ada.Text_IO.Put (Item => "$"); Dollar_Count := Dollar_Count + 1; -- Update loop control variable end loop Dollar_Loop; Ada.Text_IO.New_Line; Line_Count := Line_Count + 1; -- Update loop control variable end loop Line_Loop; end Triangle0;