-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_0537.java
More file actions
23 lines (19 loc) · 925 Bytes
/
_0537.java
File metadata and controls
23 lines (19 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.github.aditya;
public class _0537 {
public static class Solution {
public String complexNumberMultiply(String num1, String num2) {
String[] strArr1 = num1.split("\\+");
int real1 = Integer.parseInt(strArr1[0]);
int imaginary1 = Integer.parseInt(strArr1[1].substring(0, strArr1[1].length() - 1));
String[] strArr2 = num2.split("\\+");
int real2 = Integer.parseInt(strArr2[0]);
int imaginary2 = Integer.parseInt(strArr2[1].substring(0, strArr2[1].length() - 1));
return String.valueOf((real1 * real2) + (imaginary1 * imaginary2 * -1)) + "+"
+ String.valueOf((real1 * imaginary2) + (real2 * imaginary1)) + "i";
}
}
public static void main(String[] args) {
Solution sol = new Solution();
System.out.println(sol.complexNumberMultiply("78+-76i", "-86+72i"));
}
}