forked from Haresh1204/Algorithms
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplex.java
More file actions
Latest commit
32 lines (27 loc) · 662 Bytes
/
Copy pathComplex.java
File metadata and controls
32 lines (27 loc) · 662 Bytes
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
importjava.util.*;
publicclassComplex {
intre,im;
voidsetData() {
System.out.println("Enter real & imaginary no. ");
Scannersc=newScanner(System.in);
re=sc.nextInt();
im=sc.nextInt();
}
Complexadd(Complexc1,Complexc2) {
Complexobj=newComplex();
obj.re=c1.re+c2.re;
obj.im=c1.im+c2.im;
returnobj;
}
voiddisplay() {
System.out.println(re+" "+im);
}
publicstaticvoidmain(String[] args) {
// TODO Auto-generated method stub
Complexc1=newComplex();
Complexc2=newComplex();
c1.setData();c2.setData();
Complexobj=c1.add(c1,c2);
obj.display();
}
}