Question: JAVA PROBLEM Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form ???????????????? + ?????????????????????????? ? ?? where ??
JAVA PROBLEM
Create a class called Complex for performing arithmetic with complex numbers.
Complex numbers have the form ???????????????? + ?????????????????????????? ? ?? where ?? is ??1 Write a program to test your class.
Use double variable to represent the private data of the class.
Provide a constructor that enables an object of this class to be initialized when its declared.
Provide a no-argument constructor with default values in case no initializers are provided.
Provide public methods that perform the following operations:
a) Add two Complex numbers: The real parts are added together and the imaginary parts are added together.
b) Subtract two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary part of the left operand.
c) Print Complex numbers in the form (??, ??) where ?? the real part and ?? is the imaginary part.
[10] Here is a sample run:
Enter real part of the first complex number: 3
Enter imaginary part of the first complex number: 6
Enter real part of the second complex number: 2
Enter imaginary part of the second complex number: 7
First complex number is: (3.0, 6.0)
Second complex number is: (2.0, 7.0)
Addition of the complex numbers is: (5.0, 13.0)
Subtraction of the complex numbers is: (1.0, -1.0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
