I give up with this assignment
This commit is contained in:
@@ -101,14 +101,21 @@ class Complex {
|
||||
|
||||
public Complex divide(double c, double d)
|
||||
{
|
||||
return new Complex(this.a / c, this.a - d);
|
||||
double denominator = (c * c) + (this.b * this.b);
|
||||
double aNum = (this.a * c) + (this.b * this.b);
|
||||
double iNum = (this.b * c) - (this.a * d);
|
||||
double realResult = aNum / denominator;
|
||||
double imaginaryResult = iNum / denominator;
|
||||
return new Complex(realResult, imaginaryResult);
|
||||
}
|
||||
public Complex divide(Complex obj)
|
||||
{
|
||||
double denominator = this.a * this.a + this.b * this.b;
|
||||
double r = (this.a * obj.b + this.a * obj.b) / denominator;
|
||||
double i = (this.b * obj.b - this.a * obj.b) / denominator;
|
||||
return new Complex(r, i);
|
||||
double denominator = (obj.a * obj.a) + (this.b * this.b);
|
||||
double aNum = (this.a * obj.a) + (this.b * obj.b);
|
||||
double iNum = (this.b * obj.a) - (this.a * obj.b);
|
||||
double realResult = aNum / denominator;
|
||||
double imaginaryResult = iNum / denominator;
|
||||
return new Complex(realResult, imaginaryResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +131,7 @@ class Complex {
|
||||
}
|
||||
|
||||
public double abs() {
|
||||
return Math.abs(this. a + this.b);
|
||||
return Math.abs(this.a + this.b);
|
||||
}
|
||||
|
||||
public double getRealPart() {
|
||||
|
Reference in New Issue
Block a user