Complex Numbers
class ten {
int real, image;
public ten(int r, int i)
{
this.real = r;
this.image = i;
}
public void showC()
{
System.out.print(this.real + " +i" + this.image);
}
public static ten add(ten n1,ten n2)
{
ten res = new ten(0, 0);
res.real = n1.real + n2.real;
res.image = n1.image + n2.image;
return res;
}
public static void main(String arg[])
{
ten c1 = new ten(4, 5);
ten c2 = new ten(10, 5);
System.out.print("first Complex number: ");
c1.showC();
System.out.print("\nSecond Complex number: ");
c2.showC();
ten res = add(c1, c2);
System.out.println("\nAddition is :");
res.showC();
}
}