Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming with Packages Qestion Im having trouble figuring out how to finish the code for this program. It invovles complex numbers and the code

Java Programming with Packages Qestion

Im having trouble figuring out how to finish the code for this program. It invovles complex numbers and the code is comented to help.

package mypackages.types;

/**

* A class to represent a complex number.

* Split into two parts, real and imaginary.

* A complex number us defined as real + imaginary*sqaureroot(-1)

* Squareroot(-1) has the symbol of "i".

* @author Zachary Williams

*/

public class ComplexNumber

{

/**

* The imaginary portion of the complex number.

*/

private double imaginary;

/**

* The real portion of the complex number.

*/

private double real;

/**

* A no argument constructor.

* It defaults imaginary and real parts to 0.0

*/

public ComplexNumber()

{

imaginary = 0.0;

real = 0.0;

}

/**

* Used to create a ComplexNumber with passed real and imaginary values.

* @param realIn Initial real value

* @param imaginaryIn Initial imaginary value

*/

public ComplexNumber(double realIn, double imaginaryIn)

{

real = realIn;

imaginary = imaginaryIn;

}

/**

* Adds this ComplexNumber to a passed ComplexNumber, creating a new ComplexNumber.

* This is done by creating a new ComplexNumber with the two operands' real and imaginary parts summed together.

* @param operand2 ComplexNumber to be added to calling instance of ComplexNumber

* @return ComplexNumber that is the summation of calling and passed instance

*/

public ComplexNumber add(ComplexNumber operand2)

{

ComplexNumber abd = new ComplexNumber(this.real, this.imaginary);

// *** ComplexNumber *** this;

double zzz = abd.real + operand2.real;

double xxx = cde.imaginary + operand2.imaginary;

return new ComplexNumber(zzz, xxx);

}

/**

* Subtracts this ComplexNumber with a passed ComplexNumber, creating a new ComplexNumber.

* This is done by creating a new ComplexNumber with the two operands'

* real and imaginary parts subtracted from each other.

* @param operand2 ComplexNumber to be subtracted from calling instance of ComplexNumber

* @return ComplexNumber that is the difference of calling and passed instance

*/

public ComplexNumber subtract(ComplexNumber operand2)

{

}

/**

* Returns a formated String of the ComplexNumber in the form: real + imaginary * i.

* @overrides toString in class java.lang.Object

* @return formattd String of ComplexNumber

*/

public java.lang.String toString()

{

}

}

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

D)

Answered: 1 week ago

Question

Describe how online search technologies are used for marketing.

Answered: 1 week ago