-- The procedure produces a series of lines of output. -- Each of output line has a specified first and last character. -- Between the first and last characters are a specified character -- that is repeated a specified number of times. -- -- Input consists of a sequence of output line specifications, as follows: -- first character -- number of times to repeat middle character -- middle character -- last character -- -- If the last character is 'u', then the entire line -- is printed in upper case. -- -- The program continues to read line specifications until -- end of file is reached, after which the word "done" -- is printed on a separate line. -- with ada.text_io; use ada.text_io; with ada.integer_text_io; use ada.integer_text_io; -- This package contains the to_upper function with ada.characters.handling; use ada.characters.handling; procedure repeat_middle is first_char, middle_char, last_char: Character; -- Characters to print num_middle: Integer; -- Number of times to repeat middle begin -- Input and process line specifications until eof is reached while not end_of_file loop -- Get specification for a single line get(first_char); get(num_middle); get(middle_char); get(last_char); -- Convert characters to upper case, if needed if last_char = 'u' then first_char := to_upper(first_char); middle_char := to_upper(middle_char); last_char := to_upper(last_char); end if; -- Output line put(first_char); for i in 1 .. num_middle loop put(middle_char); end loop; put(last_char); new_line; end loop; -- Output final line put_line("done"); end repeat_middle;