COMPLEX NUMBER

 package com.cnc;


public class ComplexNumber {
private double real;
private double imaginary;

public ComplexNumber(double real,double imaginary){
this.real = real;
this.imaginary = imaginary;
}
public double getReal(){
return real;
}
public double getImaginary(){
return imaginary;
}
public void add(double real,double imaginary){
this.real += real;
this.imaginary += imaginary;
}
public void add(ComplexNumber complex){
add(complex.real, complex.imaginary);
}
public void subtract(double real, double imaginary){
this.real -= real;
this.imaginary-= imaginary;
}
public void subtract(ComplexNumber complex){
subtract(complex.real, complex.imaginary);
}

}

Popular posts from this blog

NUMBER PALINDROME CHALLENGE

ENCAPSULATION CHALLENGE

LARGEST PRIME FACTOR OF A NUMBER