class Complex {
    // instance variables
    double real, imag;

    // simple constructor
    public Complex () {
	this.real = 0.0;  this.imag = 0.0;
    }
        
    // constructor that takes arguments
    public Complex (double real, double imag) {
	this.real = real;  this.imag = imag;
    }

    // printComplex takes a Complex object and prints its state
    public static void printComplex (Complex c) {
	System.out.println (c.real + " + " + c.imag + "i");
    }

    // conjugate takes a Complex object and modifies it, transforming
    // it into its conjugate
    public static void conjugate (Complex c) {
	c.imag = -c.imag;
    }

    // abs takes a Complex object and returns its magnitude as a double
    public static double abs (Complex c) {
	return Math.sqrt (c.real * c.real + c.imag * c.imag);
    }

    // add takes two Complex objects and returns a new object the
    // contains their sum
    public static Complex add (Complex a, Complex b) {
	return new Complex (a.real + b.real, a.imag + b.imag);
    }
}



