-- Simple Ada program which doubles a given integer WITH text_io ; USE text_io ; -- Maks standard text I/O available PROCEDURE double IS -- program specification -- Generic Package Instantiations : PACKAGE int_io IS NEW integer_io ( integer ) ; USE int_io ; -- Global Variables : value : INTEGER ; -- value to be doubled double : INTEGER ; -- result BEGIN -- double PUT ( "Value to be doubled ? " ) ; -- prompt user GET ( value ) ; -- read number double := value * 2 ; -- multiply by two PUT ( value ) ; -- print value given by user PUT ( " * 2 = " ) ; -- print explanatory string PUT ( double ) ; -- print result NEW_LINE ; -- move on to next output line EXCEPTION -- exception handler to trap data and numerical errors WHEN numeric_error => -- trap integer overflow PUT ( "! Error - Numerical error exception raised." ) ; NEW_LINE ; WHEN data_error => -- trap non-integer input SKIP_LINE ; -- skip over rest of input line PUT ( "! Error - Data error exception raised." ) ; NEW_LINE ; END double ; -------------------------------------------------------