In this article, we will try to add and subtract these two Complex Numbers by creating a Class for Complex Number, in which:
- The complex numbers will be initialized with the help of constructor.
- The addition and subtraction will be performed with the help of function calling.
- The function will be called with the help of another class.
Input: a1 = 4, b1 = 8 a2 = 5, b2 = 7 Output: Sum = 9 + i15 Difference = -1 + i Explanation: (4 + i8) + (5 + i7) = (4 + 5) + i(8 + 7) = 9 + i15 (4 + i8) - (5 + i7) = (4 - 5) + i(8 - 7) = -1 - i Input: a1 = 9, b1 = 3 a2 = 6, b2 = 1 Output: Sum = 15 + i4 Difference = 3 + 2i
Complex number: 3 + 2i Complex number: 9 + 5i Sum of Complex number: 12 + 7i Difference of Complex number: -6 + -3i
- Program to Add Two Complex Numbers
- Java program without making class
- BigInteger subtract() Method in Java with Examples
- BigDecimal subtract() Method in Java with Examples
- Java Program for n-th Fibonacci numbers
- Java Program for GCD of more than two (or array) numbers
- Java Program for Sum of squares of first n natural numbers
- Java Program for cube sum of first n natural numbers
- Java Program for Common Divisors of Two Numbers
- Implement Triplet Class with Pair Class in Java using JavaTuples
- Implement Decade Class from Ennead Class in Java using JavaTuples
- Implement Quintet Class with Quartet Class in Java using JavaTuples
- Implement Septet Class from Sextet Class in Java using JavaTuples
- Implement Pair Class with Unit Class in Java using JavaTuples
- Implement Octet Class from Septet Class in Java using JavaTuples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.