Complex
for performing arithmetic with complex numbers.
a + bi
, where a
is the real part, b
is the imaginary part,
and i
is the square root of negative one.
real
and imaginary
, should be data type double
.
real
and imaginary
to zero (0).
print()
function that outputs the complex number in the format:
a + bi
set()
method that sets both real
and imaginary
.
get()
methods (getReal()
and getImaginary()
) that return the values real
or imaginary
.
Complex
.
Test the constructor. Complex number c1 is: 0 + 0i Test the one set() function. Complex number c2 is: 3.3 + 4.4i Test the two get() functions. Complex number c3's real part is: 5.5 Complex number c3's imaginary part is: 6.6
Click to validate the HTML code
Click to validate the CSS code