The Ada Program: complex_main.adb

  1 -- complex_main.adb:  program to read and write complex numbers
  2 
  3 with
  4    Ada.Numerics.Complex_Types,  -- Complex Numbers (Ada95 G.1.1)
  5    Ada.Numerics.Complex_Elementary_Functions,  --  (Ada95 G.1.2)
  6    Ada.Text_IO.Complex_IO,      -- Complex IO      (Ada95 G.1.3)
  7    Ada.Text_IO;
  8 
  9 use Ada, Ada.Numerics, Ada.Numerics.Complex_Elementary_Functions;
 10 
 11 procedure Complex_Main is
 12 
 13    -- IO for complex numbers in the form "(x,y)" or "x+yi"
 14    package IO is new Text_IO.Complex_IO (Complex_Types);
 15 
 16    use type Complex_Types.Complex;  -- to use "+", "*", etc. in infix
 17 
 18    X, Y: Complex_Types.Complex;
 19 
 20 begin
 21 
 22    IO.Get (X);
 23    Y := 2.0*X + X;
 24    Y := Sin (Y);
 25    IO.Put (Y, Exp=>0);
 26    Text_IO.New_Line;
 27 
 28 end Complex_Main;