Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming with Packages Qestion Im having trouble figuring out how to fin

ID: 3887029 • Letter: J

Question

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()

{

}

}

Explanation / Answer

You can take reference from the following program:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote