-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex.java
54 lines (46 loc) · 1.24 KB
/
complex.java
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
43
44
45
46
47
48
49
50
51
52
53
54
class complex
{
int real,img,i,j;
complex()
{
real=1;
img=1;
}
complex(int i)
{
real=i;
img=i;
}
complex(int i,int j)
{
real=i;
img=j;
}
void add(complex a,complex b)
{
img=img+a.img+b.img;
real=real+a.real+b.real;
}
void disp()
{
System.out.print(+ real +" + "+ img +"i");
System.out.println();
}
public static void main(String args[])
{
complex a = new complex();
complex b = new complex(3);
complex c = new complex(12,23);
System.out.println("The Three Complex Numbers Are : ");
System.out.println();
System.out.print("no argument : ");
a.disp();
System.out.print("one argument : ");
b.disp();
System.out.print("two argument : ");
c.disp();
c.add(a,b);
System.out.print("Addition Is : ");
c.disp();
}
}