()
| 34 | } |
| 35 | // Function to multiply two complex numbers |
| 36 | public void mult() { |
| 37 | double s1, s2, s3, rs2; |
| 38 | s1 = real1 * real2; |
| 39 | s2 = (real1 * imag2) + (real2 * imag1); |
| 40 | rs2 = Math.round((s2 * 100)/100); |
| 41 | if (imag1 == 0 || imag2 == 0) { |
| 42 | s3 = 0; |
| 43 | } |
| 44 | else { |
| 45 | s3 = (-1) * (imag1 * imag2); |
| 46 | } |
| 47 | s1 = s1 + s3; |
| 48 | System.out.println("Multiplication is: " + s1 + " + " + rs2 + "i"); |
| 49 | |
| 50 | } |
| 51 | // Function to divide two complex numbers |
| 52 | public void div() { |
| 53 | double d1, d2, d3, d4, d5, d6; |