Experiment 01:: Import Import Class Double Double
Experiment 01:: Import Import Class Double Double
/*
1.Classes and objects: Design a class ‘Complex ‘with data members for real and
imaginary parts. Provide default and Parameterized constructors. Write a program to
perform arithmetic operations of two complex numbers.
*/
import java.text.DecimalFormat;
import java.util.*;
class Complex {
double real;
double imaginary;
Complex(){
this(0,0);
}
Output:
Enter Num1 Real part: 12
Enter Num1 Imaginary part: 7
Enter A: Addition, S: Subtraction, M: Multiplication, D: Division, E:
Exit: S
Enter Num2 Real part: 22
Enter Num2 Imaginary part: 13