Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions