Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

What is future value and how is it calculated?

Answered: 1 week ago

Question

Question Can any type of stock or securities be used in an ESOP?

Answered: 1 week ago