Question: Write a C + + program that creates a class called complex performing arithmetic with complex numbers. Write a program to test your class. Complex

Write a C++ program that creates a class called complex performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form:
- realPart + imaginaryPart * i
- Where i is -1
Use double variables to represent data of the class. Provide a constructor that
enables an object of this class to be initialized when it is declared. The constructor
should contain default values in case no initializers are provided. Also, a function
to assign data to data fields. Provide functions for each of the following:
a. Adding two complex numbers. The real parts are added together and the
imaginary parts are added together.
b. Subtracting 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. Multiplying two Complex numbers.
d. Printing complex numbers in the form (a, b), where a is the real part and b is
the imaginary part.
Example of what results should look like:
a =(9.5,7.7)
b =(1.2,3.1)
a + b =(10.7,10.8)
a b =(8.3,4.6)
a * b =(-12.47,38.69)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!