Assignment 1
Assignment 1
//Problem Statement::
/*
Design a class ‘Complex ‘with data members for real and imaginary part.
Provide default and Parameterized constructors. Write a program to
perform
arithmetic operations of two complex numbers.
*/
import java.util.*;
class Complex_No{
float real,img;//data member
public Complex_No(){
//default constructor
real=0;
img=0;
}
public Complex_No(float a ,float b){
//parameterized constructor
real=a;
img=b;
}
real=(C1.real*C2.real+C1.img*C2.img)/(C2.real*C2.real+C2.img*C2.
img);
//real part of complex number
img=(C1.img*C2.real-
C1.real*C2.img)/(C2.real*C2.real+C2.img*C2.img);
//img part of complex number
System.out.println("Division of Complex Numbers
=("+real+")+("+img+")i");
//printing division of two complex number
}
System.out.print("\n");
cal.Display(Com1,Com2);
//calling display function
System.out.print("\n");
cal.AddNumbers(Com1,Com2);
//calling addition function
cal.SubNumbers(Com1,Com2);
//calling substraction function
cal.MultiNumbers(Com1,Com2);
//calling multiplication function
cal.DivNumbers(Com1, Com2);
//calling division function
/*
OUTPUT
*/