Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class for complex numbers. A complex number is a number of the form: a + b*i where for our purposes, a and b

Define a class for complex numbers. A complex number is a number of the form: a + b*i where for our purposes, a and b are numbers of type double , and i is a number that represents the quantity image text in transcribed

Represent a complex number as two values of type double. Name the member variables real and imaginary. (The variable for the number that is multiplied by i is the one called imaginary.) Call the class Complex.

- Include a constructor with two parameters of type double that can be used to set the member variables of an object to any values.

- Include a constructor that has only a single parameter of type double ; call this parameter realPart and define the constructor so that the object will be initialized to realPart + 0*i . Include a default constructor that initializes an object to 0 (that is, to 0 + 0*i).

Overload all the following operators so that they correctly apply to the type Complex: +, -, *, > optinal)

- The sum of The product of two complex numbers is given by the following formula: (a + b*i)+(c + d*i) = (a+c)+(b+d)*i

- The difference of The product of two complex numbers is given by the following formula: (a + b*i)-(c + d*i) = (a-c)+(b-d)*i

- The product of two complex numbers is given by the following formula: (a + b*i)*(c + d*i) = (a*c - b*d) + (a*d + b*c)*i

You should also write a test program:

- Instantiate four complex numbers C1=(1+4*i), C2=(-3-7i), C3=(4*i)and C4=(-3+ i)

- Add, subtract and multiply C1 and C2.

- Add, subtract and multiply C3 and C4.

- Use the overloaded

image text in transcribed

*WRITE THE PROGRAM IN C++ FORMAT AND MAKE SURE IT RUNS*

*DO NOT PUT THE BODY OF THE FUNCTION INSIDE THE CLASS*

*USE ORDER OF OPERATIONS FOR MATH PART*

10(i*i= -1) / (1 + 4*i) + (-3 - 7*i) = -2 - 3*i i (1 + 4*i) - (-3 - 7*i) = 4 + 11*i | (1 + 4*i) * (-3 - 7*i) = 25 - 19*i - i (4*i) + (-3 + i) = -3 + 5*i ) ) (4*i) - (-3 + i) = 3 + 3*i i (4*i) * (-3 + i) = -4 - 12*i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago