-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexTest.java
More file actions
29 lines (21 loc) · 932 Bytes
/
ComplexTest.java
File metadata and controls
29 lines (21 loc) · 932 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
import java.util.Scanner;
public class ComplexTest {
public static void main(String args[]) {
Scanner scanner= new Scanner(System.in);
System.out.println("Enter the first real number");
int real1=scanner.nextInt();
System.out.println("Enter the first imaginary number");
int imaginary1=scanner.nextInt();
Complex complex1=new Complex();
complex1.set(real1,imaginary1);//Setting the input
System.out.println("Enter the second real number");
int real2=scanner.nextInt();
System.out.println("Enter the second imaginary number");
int imaginary2=scanner.nextInt();
Complex complex2=new Complex();
complex2.set(real2,imaginary2);//Calling the Complex by its object
Complex complexsum=new Complex();
complexsum=Complex.sum(complex1, complex2);
System.out.println("New complex Number is " +complexsum.real + " +" +complexsum.imaginary);
}
}