Code:
import java.util.*;
class complex
{
int a,b,c,d;
complex(int a,int b,int c,int d){
this.a=a;
this.b=b;
this.c=c;
this.d=d;
}
void complex(complex r1)
{
int k,n;
k=a+c;
n=b+d;
System.out.println("sum of complex numbers");
System.out.println(k+"+"+n+"i");
}
}
class complex1
{
public static void main(String args[])
{
int a,b,c,d;
Scanner in=new Scanner(System.in);
System.out.println("enter the real number of first complex number");
a=in.nextInt();
System.out.println("enter the imaginary number of first complex number");
b=in.nextInt();
System.out.println("enter the real number of second complex number");
c=in.nextInt();
System.out.println("enter the imaginary number of second complex number");
d=in.nextInt();
complex r1=new complex(a,b,c,d);
r1.complex(r1);
}
}
No comments:
Post a Comment