with ada.text_io; -- context clause with ada.integer_text_io; -- context clause procedure using_files is -- procedure header (no parameters) -- declarations input_file_name : String (1..80); output_file_name : String (1..80); blank_string : constant String (1..80) := (others => ' '); input_file : ada.text_io.file_type; output_file : ada.text_io.file_type; last_in : integer; last_out : integer; temp_num : integer; square_num: integer; begin -- procedure input_file_name := blank_string; output_file_name := blank_string; temp_num := 0; ada.text_io.put("Enter input file name."); -- prompt ada.text_io.get_line(input_file_name, last_in); --Input file has to exist or Ada will throw an exception. ada.text_io.open(file => input_file, mode=> ada.text_io.in_file, name => input_file_name(1..last_in)); ada.text_io.put (" INPUT file successfully opened "); -- debugging statement ada.text_io.new_line; ada.text_io.put("Enter output file name."); -- prompt ada.text_io.get_line(output_file_name, last_out); ada.text_io.put (" you entered "); -- echo of input ada.text_io.put_line (output_file_name); -- Output file does not have to exist - will be created ada.text_io.create(file => output_file, mode => ada.text_io.out_file, name => output_file_name(1..last_out)); ada.text_io.put (" OUTPUT file successfully created "); -- put a heading in the output file ada.text_io.put_line (output_file, " Number Square"); --Read the five integers from the file. for i in 1..5 loop ada.integer_text_io.get(file => input_file, item => temp_num); -- named parameters square_num := temp_num * temp_num; ada.integer_text_io.put(file => output_file, item => temp_num, width => 6); ada.integer_text_io.put (file => output_file, item => square_num, width => 12); ada.text_io.new_line(file =>output_file); end loop; ada.text_io.close(file => input_file); -- closes input file ada.text_io.close(file => output_file); -- closes output file -- remind user where data came from and went to:input and output file names ada.text_io.put (" input came from "); ada.text_io.put_line (input_file_name); ada.text_io.put (" output can be found in "); ada.text_io.put_line (output_file_name); end using_files;