-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput_Output_ComplexNum.java
More file actions
51 lines (50 loc) · 2.51 KB
/
Copy pathInput_Output_ComplexNum.java
File metadata and controls
51 lines (50 loc) · 2.51 KB
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
import java.util.Scanner;
public class Input_Output_ComplexNum {
public void buttonChoice(int button){
Scanner scanner = new Scanner(System.in);
if (button == 1) {
System.out.println("Enter a real part and an imaginary part of your complex number.");
double real = scanner.nextDouble();
double img = scanner.nextDouble();
ComplexNum newComplexNum = new ComplexNum(real, img);
newComplexNum.CreateComplexNum(real, img);
System.out.println(newComplexNum.toString());
}
else if (button == 2){
System.out.println("Enter a real part and an imaginary part of your complex number.");
double real = scanner.nextDouble();
double img = scanner.nextDouble();
ComplexNum newComplexNum = new ComplexNum(real, img);
newComplexNum.CreateComplexNum(real, img);
System.out.println(newComplexNum.trig());
}
else if (button == 3){
System.out.println("Enter a real part and an imaginary part of your first complex number.");
double real = scanner.nextDouble();
double img = scanner.nextDouble();
ComplexNum first = new ComplexNum(real, img);
first.CreateComplexNum(real, img);
System.out.println("Enter a real part and an imaginary part of your second complex number.");
real = scanner.nextDouble();
img = scanner.nextDouble();
ComplexNum second = new ComplexNum(real, img);
second.CreateComplexNum(real, img);
System.out.println("It's the addition of your two numbers.");
System.out.println(first.sum(second));
}
else if (button == 4){
System.out.println("Enter a real part and an imaginary part of your first complex number.");
double real = scanner.nextDouble();
double img = scanner.nextDouble();
ComplexNum first = new ComplexNum(real, img);
first.CreateComplexNum(real, img);
System.out.println("Enter a real part and an imaginary part of your second complex number.");
real = scanner.nextDouble();
img = scanner.nextDouble();
ComplexNum second = new ComplexNum(real, img);
second.CreateComplexNum(real, img);
System.out.println("It's the multiplication of your two numbers.");
System.out.println(first.mult(second));
}
}
}