// FILL IN this method. public ComplexNumber conjugate() { // Return the complex
ID: 3673581 • Letter: #
Question
// FILL IN this method.
public ComplexNumber conjugate() {
// Return the complex conjugate of the complex number represented by
// this object.
// DO NOT return null.
// The following statement is a temporary placeholder to prevent a
// compiler error. Remove when you implement this method.
return null;
}
// FILL IN this method.
public ComplexNumber add(ComplexNumber other) {
// Return the sum of the complex number represented by this object and
// the complex number represented by the parameter called other
// (i.e., this + other).
// DO NOT return null.
// The following statement is a temporary placeholder to prevent a
// compiler error. Remove when you implement this method.
return null;
}
Explanation / Answer
public ComplexNumberNumber conjugate()
{
ComplexNumber conj = new ComplexNumber();
conj.dReal = dReal;
conj.dImaginary = -dImaginary;
return (conj);
}
public ComplexNumberNumber add(ComplexNumberNumber other)
{
ComplexNumber sum = new ComplexNumber();
sum.dReal = dReal + other.dReal;
sum.dImaginary = dImaginary + other.dImaginary;
return (sum);
}
return null;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.