Sasha D.

asked • 10/18/21

java program to perform arithmetic operations on complex numbers

Design and implement a ComplexNumber class that represents the real and imaginary parts as double values and provides at least the following methods:

  1. Constructors for default and explicit initialization.
  2. A method to read (get input) a complex number.
  3. A method to print a complex number as (a, b). Have 2 decimals for both.
  4. A method called getReal that returns the real part of a complex number.
  5. A method called getImaginary that returns the imaginary part of a complex number.
  6. Methods equals, copy, getCopy, toString.
  7. Arithmetic methods to add, subtract, multiply, and divide two complex numbers.
  8. A method called cAbs to implement the absolute value of a complex number.
  9. To test your class write a client that has at least a function menu() with options for the methods implemented and an option to exit. Your program should loop until the user chooses to exit. In this loop you are required to use a switch statement for all possible cases

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.