programming java. class methods, like public pravite protected to string.

Anonymous
timer Asked: Mar 9th, 2016

Question description

A complex ("imaginary") number has the form a + bi, where a is called the real part, b is called the imaginary part, and i = sqrt(-1). A complex number a + bi can be expressed as the ordered pair of real numbers (a, b). Arithmetic operations on two complex numbers (a, b) and (c, d) are as follows:

Addition:  (a, b) + (c, d) = (a + c, b + d)

Subtraction:  (a, b) - (c, d) = (a - c, b - d)

Multiplication: (a, b) * (c, d) = (a * c - b * d, a * d + b * c)

Division:  (a, b) / (c, d) = ((a * c + b * d)/(c2 + d2), (b * c - a * d)/(c2 + d2))

Absolute value: |(a, b)| = sqrt(a2 + b2)

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

  • Constructors for default and explicit initialization.
  • A method to read a complex number. Look at the sample output screen for the design required.
  • A method to print a complex number as (a, b). Have 2 decimals for both.
  • A method called getReal that returns the real part of a complex number.
  • A method called getImaginary that returns the imaginary part of a complex number.
  • Methods equal, copy, getCopy, toString.
  • Arithmetic methods to add, subtract, multiply, and divide two complex numbers.
  • A method called cAbs to implement the absolute value of a complex number.

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

-----------------------

 this is class obj methods.... so use class obj method.


Tutor Answer

(Top Tutor) Studypool Tutor
School: New York University
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors