-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex.jav
42 lines (41 loc) · 985 Bytes
/
complex.jav
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class complex
{
int real;
int img;
complex();
{
System.out.println("********Complex Number operation *************");
}
complex(int r,int i)
{
real=r;
img=i;
}
complex( complex c1, complex c2)
{
r=c1.real+c2.real;
i= c1.img+c2.img;
System.out.prinf("Addition is %d+%di",r,i);
r=c1.real-c2.real;
i= c1.img-c2.img;
System.out.prinf("\nSubtraction is %d+%di",r,i);
r=(c1.real*c2.real)-(c1.img*c2.img);
i=(c1.real*c2.img)+(c2.real*c1.img)
System.out.prinf("\nMultipliction is %d+%di",r,i);
}
public static void main(String arg[])
{
Scanner sc= new scanner(sytem.in);
complex c=new complex();
System.out.println("enter real and imaginary part of complex number 1");
n1= sc.nextnt();
System.out.prin(i);
n2=sc.nextInt();
System.out.println("enter real and imaginary part of complex number 2");
n3= sc.nextnt();
System.out.prin(i);
n4=sc.nextInt();
complex c1=new complex(n1,n2);
complex c2=new complex(n3,n4);
complex c3= new complex(c1,c2);
}