import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class DisplayComplex extends Applet 
{
   private Complex real;
   private Complex fake;
   public float realx1, realx2, false1, false2;

   public void init()
   {
      real = new Complex(1.0f, 2.0f);
      fake = new Complex(3.0f, 4.0f);
   }

   public void paint(Graphics g)
   {
      realx1 = real.getReal();
      false1 = real.getImaginary();
      realx2 = fake.getReal();
      false2 = fake.getImaginary();

      real.passParameter(realx1,false1,realx2,false2);

      real.sum();

      real.theProduct();
      real.display(g);
   }
}

    class Complex
    {
      private float x,y;
      private float sum1, sum2;
      private int xCoord, yCoord;
      private float x1,x2,y1,y2;
      private float realProd, imagProd;

      public Complex(float xNum, float yNum)
      {
        x = xNum;
        y = yNum;
      }

      public float getReal()
      {
        return x;
      }

      public float getImaginary()
      {
        return y;
      }

      public void passParameter(float a, float b, float c, float d)
      {
        x1 = a;
        y1 = b;
        x2 = c;
        y2 = d;
      }

      public void sum()
      {
         sum1 = x1+x2;
         sum2 = y1+y2;
      }

      public void theProduct()
      {
        realProd = (x1*x2)-(y1*y2);
        imagProd = (x1*y2)+(x2*y1);
      }

      public void display(Graphics g)
      {
        g.drawString("The Complex Number 1 is "+x1+ "+ " +y1+ "i ",50,50);
        g.drawString("The Complex number 2 is "+x2+ "+ " +y2+ "i ",50,70);
        g.drawString("The Sum is " +sum1+ "+" +sum2+ "i", 50,100);
        g.drawString("The Product is "+realProd+ "+" +imagProd+ "i" ,50,120);
      }
  }




