Commit 88767af1 authored by antony.adewunmi-jones's avatar antony.adewunmi-jones

first commit

parent de95c2bd
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -2,6 +2,7 @@ public class Complex {
public double real;
public double imag;
public double r, i;
public Complex()
{
......@@ -26,20 +27,54 @@ public class Complex {
{
return real;
}
////////////////////////////
public double magnitude()
{
return 1.0;
double r2 = Math.pow(real, 2);
double i2 = Math.pow(imag, 2);
double ri = r2 + i2;
double risqrt = Math.sqrt(ri);
return risqrt;
}
public double argument()
{
return 1.0;
double arg_tan = Math.atan2(imag,real);
return arg_tan;
}
public String toString()
{
return "";
String words;
if (imag == 0){
words = Double.toString(real);
}
else if (real == 0){
words = ("j"+imag);
}
else if (imag<0){
imag = 0-imag;
words = (real+" - j"+imag);
}
else{
words = (real+" + j"+imag);
}
return words;
}
public Complex add(Complex complexNum)
......
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