Commit 52facc68 authored by aurian.foulner's avatar aurian.foulner

origin

parent de95c2bd
No preview for this file type
public class Complex {
public double real;
public double real;
public double imag;
public Complex()
......@@ -29,25 +29,35 @@ public class Complex {
public double magnitude()
{
return 1.0;
return Math.sqrt(real*real + imag*imag);
}
public double argument()
{
return 1.0;
return Math.atan2(imag, real);
}
public String toString()
{
return "";
}
String answer = "";
if (real == 0){
answer="j" + imag;}
else if (imag ==0){
answer = Double.toString(real);}
else if ( imag < 0){
answer = Double.toString(real)+ " - " + "j" + Math.abs(imag);}
else {
answer = Double.toString(real) + " + " + "j" + imag;}
return answer;
};
public Complex add(Complex complexNum)
{
Complex answer = new Complex(0.0,0.0);
answer.imag = complexNum.imag() + this.imag;
answer.real = complexNum.real() + this.real;
return answer;
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment