0% found this document useful (0 votes)
5 views1 page

Complex Number

Uploaded by

gamzone08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Complex Number

Uploaded by

gamzone08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.io.

*;
import java.util,Scanner;

class ComplexNumber{
int real;
int imag;

public ComplexNumber(int r,int i){


Scanner sc = new Scanner(system.in);

this.real=r;
this.imag=i;
}

public void readData(){

System.out.println("Enter the real Number:")


real=sc.nextInt();
System.out.println("Enter the imag Number:")
imag=sc.nextInt();
}

public void showData(){

System.out.println("The real number is " +real+ "and imaginary number is


"+image+"+i");
}

public void addComplexNumber(ComplexNumber c1,ComplexNumber c2){


real=c1.real + c2.real;
imag=c1.imag + c2.imag;
}

public class AddTwoComplex{


public static void main(string[] arg){

ComplexNumber c1= new ComplexNumber();


ComplerNumber c2= new ComplexNumber();
ComplerNumber c3= new ComplexNumber();

System.out.println("Enter First Complex Number:");


c1.readData();

System.out.println("Enter Second Complex Number:");


c2.readData();

System.out.println("Sum of Two Complex Number:");


c3.showData();
}
}
}

You might also like