Question: JAVA PROBLEM create a class called Complex for performing arithmetic with complex numbers, complex numbers have the form realpart + imaginarypart * I where i
JAVA PROBLEM
create a class called Complex for performing arithmetic with complex numbers, complex numbers have the form realpart + imaginarypart * I where i is sqrt of -1 using floating point variables to represent the private data of the class. provide a constructor function that enables an object of this class to be initialized when it is declared. the constructor should contain default values in case no initializers are provided. provide public member functions for each of the following a) addition of the complex numbers: the real parts are added together and the imaginary parts are added together . b) subtraction of the two complex numbers: the real part of the right operand is subtracted from the real part of the left operand and the imaginary part of the right operand is subtracted from the imaginary part of the left operand c) printing complex numbers in the form (a,b) where a is the real part and b in the imaginary part
Here is a sample run:
Enter real part of the first complex number: 3
Enter imaginary part of the first complex number: 6
Enter real part of the second complex number: 2
Enter imaginary part of the second complex number: 7
First complex number is: (3.0, 6.0)
Second complex number is: (2.0, 7.0)
Addition of the complex numbers is: (5.0, 13.0)
Subtraction of the complex numbers is: (1.0, -1.0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
