The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science

Week 2 Homework

1. Write a package specification to implement complex numbers--numbers that contain a real and imaginary part. Make the type definition private. Provide two operations: addition and subtraction.

2. Write the body of the package defined in problem 1.

3. Define encapsulation and explain how encapsulation is accomplished in Ada.

4. Define the package specification for a child package of the package defined in problem 1 that performs input and output of complex numbers.

5. Write a client program that uses the packages defined in the previous problems. The program should read in two complex numbers, add them and print out their sum.