Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

complex numbers in java

class ComplexNumber {
 
    int real, image;
 
 
    public ComplexNumber(int r, int i)
    {
        this.real = r;
        this.image = i;
    }
 
  
    public void showC()
    {
        System.out.print(this.real + " +i" + this.image);
    }
 
    
    public static ComplexNumber add(ComplexNumber n1,
                                    ComplexNumber n2)
    {
 
        
        ComplexNumber res = new ComplexNumber(0, 0);
 
     
        res.real = n1.real + n2.real;
 
       
        res.image = n1.image + n2.image;
 
     
        return res;
    }
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #complex #numbers #java
ADD COMMENT
Topic
Name
9+9 =