1--
2-- Copyright(C) 1998
3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4--
5-- Permission to use, copy, modify, and distribute this
6-- software and its documentation for EDUCATIONAL purposes
7-- and without fee is hereby granted provided that this
8-- copyright notice appears in all copies.
9--
10
11-- date : January 1, 1998.
12-- author : Salih Yurttas.
13
14-- purpose : Error handling by exceptions.
15
16-- error_handling_11.adb
17
18
19with Ada.Text_IO;
20use Ada.Text_IO;
21
22procedure Error_Handling_11 is
23
24 package Int_IO is new Integer_IO(Integer);
25 use Int_IO;
26
27 N : Integer := 4;
28
29 D : Integer := 16;
30
31 Value : Integer;
32
33 E : exception;
34
35begin
36
37 for I in 1..N
38 loop
39
40 loop
41 begin
42
43 loop
44 begin
45
46 New_line;
47
48 Put("--> Value : ");
49 Get(Value);
50
51 exit when Value in 1..16;
52 raise E;
53
54 exception
55 when E => New_Line;
56 Put_Line("Try again : Value in 1..16");
57 Skip_line;
58 end;
59 end loop;
60
61 D := D/Value;
62
63 Put(D);
64 New_line;
65
66 exit;
67 exception
68 when CONSTRAINT_ERROR => New_Line;
69 Put_Line("Try Again... 1..16");
70 end;
71 end loop;
72
73 end loop;
74
75end Error_Handling_11;