forked from amanss00/ForNewbies
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_of_complex.java
More file actions
57 lines (35 loc) · 910 Bytes
/
add_of_complex.java
File metadata and controls
57 lines (35 loc) · 910 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Scanner;
public class Complex01 {
private int real1,img1,real2,img2;
private int real3,img3;
public void getdata()
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter First Complex Number :");
real1 = obj.nextInt();
img1 = obj.nextInt();
System.out.println("Enter Second Complex NUmber :");
real2 = obj.nextInt();
img2 = obj.nextInt();
}
public void add()
{
real3 = real1 + real2;
img3 = img1 + img2;
}
public void display()
{
System.out.println("First Complex Number is :" +real1+ "+" +img1+ "i");
System.out.println("Second Complex Number is :" +real2+ "+" +img2+ "i");
System.out.println("The Addition of Numbers is :" +real3+ "+" +img3+ "i");
}
}
//File 2 :-
public class Complex_01 {
public static void main(String[] args) {
Complex01 obj = new Complex01();
obj.getdata();
obj.add();
obj.display();
}
}