Question
Beginner Java homework 2- Complete the complex numbers functions as instructed in the comments above the functions: public class Complex { private double real; private
Beginner Java homework 2- Complete the complex numbers functions as instructed in the comments above the functions:
public class Complex {
private double real;
private double imaginary;
// Constructs an instance, given its real and imaginary components.
public Complex(double real, double imaginary)
{
}
// Constructs an instance that duplicates source.
public Complex(Complex source)
{
}
// Getter method.
public double getReal()
{
}
// Getter method.
public double getImaginary()
{
}
// 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
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
public static Complex multiply(Complex c1, Complex c2)
{
}
// The "norm" of complex number a+bi is the square root of (a^2 + b^2).
public double norm()
{
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started