Question
Use the following UML diagram as a guide to write two classes to show arithmetic operations on complex number (objects). For this problem, you need
Use the following UML diagram as a guide to write two classes to show arithmetic operations on complex number (objects). For this problem, you need to track (count) the total number of complex objects created. Remember each complex number has two numbers (real, imaginary). All the numbers are of double type. To save some time, use the toString( ) method provided (at the end) to print complex numbers ( x, yi).
Your result should look like the following:
The number of Complex objects: 2
c1: 2.5 - 4.3i
c2: -12.34 + 4.33i
Real part of c1: 2.5
Imaginary part of c1: -4.3
Testing Mutators - Updated c2: -4.0 + 3.0i
c1 magnitude: 4.973932046178355
c2 magnitude: 5.0
c3: 6.5i
c4: 2.5 - 4.3i
The number of Complex objects: 4
Test: c1==c4 => true
**** Complex Arithmetic test ****
c1 = 2.5 - 4.3i c2 = -4.0 + 3.0i
c1 + c2 = -1.5 - 1.2999999999999998i
c1 - c2 = 6.5 - 7.3i
c1 * c2 = 2.8999999999999986 + 24.7i
The number of Complex objects created: 7
Assignmentt .trial a imaginary: double a real: double int a Comple double double) Complex(double)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started