Question: Write a Java class Complex for dealing with complex number. Your class must have the following properties and behaviors: Instance variables : re for the

Write a Java class Complex for dealing with complex number. Your class must have the following properties and behaviors: Instance variables : re for the real part of type double and im for imaginary part of type double. Constructor: o A default constructor, it should initialize the number to (0, 0) o A constructor with parameters, it creates the complex object by setting the two fields to the passed values. Instance methods: o public Complex add (Complex otherNumber): This method will find the sum of the current complex number and the passed complex number. The methods returns a new Complex number which is the sum of the two. o public Complex subtract (Complex otherNumber): This method will find the difference of the current complex number and the passed complex number. The methods returns a new Complex number which is the difference of the two. o public Complex multiply (Complex otherNumber): This method will find the product of the current complex number and the passed complex number. The methods returns a new Complex number which is the product of the two. o public Complex divide (Complex otherNumber): This method will find the division of the current complex number by the passed complex number. The methods returns a new Complex number (refere to mathematic background to learn how to multiply and divide two complex numbers) o public double getAbsolute(): This method returns the absolute value of a complex number (2 + 2) o public double getPhase(): This method returns the phase value of a complex number (tan1 ) o public void printMe(): This method allows the complex number to be easily printed out to the screen in the form re +j im if re is zero shoul print j im else if im is zero should print re and if im<0 should print re- j im

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!