clean up PrintRoots2.
This commit is contained in:
parent
306a13f866
commit
b4fff86a37
|
@ -1,11 +1,13 @@
|
||||||
-- print_roots2 demonstrates runtime exceptions.
|
-- print_roots2 demonstrates runtime exceptions.
|
||||||
with Ada.Text_IO;
|
with Ada.Text_IO;
|
||||||
with Ada.Float_Text_IO;
|
with Ada.Float_Text_IO;
|
||||||
|
with Ada.Numerics;
|
||||||
with Ada.Numerics.Generic_Elementary_Functions;
|
with Ada.Numerics.Generic_Elementary_Functions;
|
||||||
|
|
||||||
procedure Print_Roots is
|
procedure Print_Roots2 is
|
||||||
use Ada.Text_IO;
|
use Ada.Text_IO;
|
||||||
use Ada.Float_Text_IO;
|
use Ada.Float_Text_IO;
|
||||||
|
use Ada.Numerics;
|
||||||
package Numerics is new Ada.Numerics.Generic_Elementary_Functions(Float);
|
package Numerics is new Ada.Numerics.Generic_Elementary_Functions(Float);
|
||||||
use Numerics;
|
use Numerics;
|
||||||
X: Float;
|
X: Float;
|
||||||
|
@ -16,8 +18,15 @@ begin
|
||||||
loop
|
loop
|
||||||
Get(X);
|
Get(X);
|
||||||
exit when X = 0.0;
|
exit when X = 0.0;
|
||||||
Put("Root of "); Put(X); Put(" is ");
|
begin
|
||||||
|
Put("Root of "); Put(X); Put(" is ");
|
||||||
|
exception
|
||||||
|
when Ada.Numerics.Argument_Error =>
|
||||||
|
Put("not calculable: X must be >= 0");
|
||||||
|
when Constraint_Error =>
|
||||||
|
Put("not calculable: X must be >= 0");
|
||||||
|
end;
|
||||||
Put(Sqrt(X));
|
Put(Sqrt(X));
|
||||||
New_Line;
|
New_Line;
|
||||||
end loop;
|
end loop;
|
||||||
end Print_Roots;
|
end Print_Roots2;
|
||||||
|
|
Loading…
Reference in New Issue