Java Code for Complex Number

This java programming code is used to find the complex number. You can select the whole java code by clicking the select option and can use it. When you click text, the code will be changed to text format. This java program code will be opened in a new pop up window once you click pop-up from the right corner. You can just copy, paste this java code and use it to find the complex number.

import java.util.*;
import java.lang.*;
import java.math.*;
class Complex_Number
{  
    public static void main(String args[])
    {
    int a1,a2,b1,b2,m1,m2,m3,m4,d,r1,s;
    double r,r2,x,y;
    a1=5; b1=2; a2=7;b2=-4;d=0;s=0;
    //Multiplication of complex number
    m1=a1*a2;
    m2=b1*(-(b2));
    m3=a1*b2;
    m4=a2*b1;
    int m5=(m1+m2);
    int m6=m3+m4;
    if(m6>0)
    {
        System.out.println("
Multiplication of complex num:"+m5+"+"+m6+"i");
    }
    else
    {
        System.out.println("
Multiplication of complex num:"+m5+" "+m6+"i");
    }
    //Division of complex number
    d=(a2*a2) +(b2*b2);
    if(m6>0)
    {
        System.out.println("
Division of complex num: ("+m5+"+"+m6+"i)/"+d);
    }
    else
    {
        System.out.println("
Division of complex num: ("+m5+" "+m6+"i)/"+d);
    }
    //Squareroot of complex number
    r1=(5*5)+(2*2);
    r=Math.sqrt(r1);
    r2=(r-a1)/2;
    y=Math.sqrt(r2);
    x=b1/(2*y); 
    String x1=String.format("%.6f",x);
    x=Double.parseDouble(x1);
    String x2=String.format("%.6f",y);
    y=Double.parseDouble(x2);
    System.out.println("
Square Root: "+x1+" +"+x2+"i");
    System.out.println("
Square Root:-"+x1+" -"+x2+"i");
} 
}
Other Programming Codes
Online Calculator : Complex Number
Click on the select code link to copy and paste this free java program code for complex number.

english Calculators and Converters


Sitemap