Question: Given the code below, I need help to complete the Complex add, Complex multiply, and double norm methods. Instructions on how to complete these methods

Given the code below, I need help to complete the Complex add, Complex multiply, and double norm methods. Instructions on how to complete these methods are in the comments before the method. I am having a hard time implementing complex numbers because I do not know how to implement them

package func;

public class Complex

{

private double real;

private double imaginary;

// Constructs an instance, given its real and imaginary components.

public Complex(double real, double imaginary)

{

this.real = real;

this.imaginary = imaginary;

}

// Constructs an instance that duplicates source.

public Complex(Complex source)

{

this.real = source.getReal();

this.imaginary = source.getImaginary();

}

// Getter method.

public double getReal()

{

return real;

}

// Getter method.

public double getImaginary()

{

return imaginary;

}

// Constructs and returns a new instance of Complex that represents the sum of its inputs,

// according to the following formula:

//

// (a+bi) plus (c+di) = (a+c) + (b+d)i

//

// Complete this method, then remove this comment line.

//

public static Complex add(Complex c1, Complex c2)

{

}

//

// Constructs and returns a new instance of Complex that represents the product of its inputs,

// according to the following formula:

//

// (a+bi) times (c+di) = a*c + a*di + bi*c + bi*di = ac + (ad+bc)i + bd*ii

// Since ii is -1 by definition, the last term is -bd ==> the result is ac-bd + (ad+bc)i

//

// Complete this method, then remove this comment line.

//

public static Complex multiply(Complex c1, Complex c2)

{

}

//

// The "norm" of complex number a+bi is the square root of (a^2 + b^2).

// Complete this method, then remove this comment line.

//

public double norm()

{

}

}

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!