Question: Complex numbers have format a + b i, where i = ((sqrt) -1). Values a and b are real numbers. Number a is called real

Complex numbers have format a + b i, where i = ((sqrt) -1). Values a and b are real numbers. Number a is called real part and b is called imaginary part of the complex number a + b i.

The operations to add, subtract and multiply two complex numbers are defined as follows:

Addition: (a+b i) + (c + di) = (a+c) + (b+d)i

Subtraction: (a+b i) - (c + di) = (a-c) + (b-d)i

Multiplication: (a+b i) * (c + di) = (ac -bd) + (ad + bc)i

Design an application with two classes. Class ComplexNumber has instance data rPart and iPart. Constructor accepts two type double parameters which are used to initialize rPart and iPart. The following three methods can add, subtract, or multiply the complex number that will invoke the method and the complex number other that is in the parameter list.

public ComplexNumber add (ComplexNumber other)

public ComplexNumber subtract (ComplexNumber other)

public ComplexNumber multiply (ComplexNumber other)

Class ComplexNumber has also getter methods to get rPart and iPart, and method toString that returns string representation of complex number (which displays rPart and iPart followed by imaginary value i).

Class ComplexNumberTester has main method. Create two complex numbers complexNumber1 and complexNumber2 from the class ComplexNumber and invoke methods to add, subtract and multiply those two numbers. For each operation display both complex numbers, operation performed, and result.

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!