Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 . [ 2 0 points A complex number is a number that can be expressed in the form a + ib , where

Exercise 1.[20 points
A complex number is a number that can be expressed in the form a + ib, where a and b are real numbers, and i is a solution of the equation x2=-1. Because no real number satisfies this equation, i is called an imaginary number. For the complex number a ib, a is called the real part, and b is called the imaginary part. When performing the arithmetic operations on complex numbers, remember to combine "similar" terms, i.e., the real and the imaginary parts. For two complex numbers a + ib and c + id, the following operations are defined as follows:
Addition Rule: (a + ib)+(c + id)=(a + c)+ i(b + d),
Subtraction Rule: (a + ib)-(c + id)=(a - c)+ i(b - d),
Multiplication Rule: (a + ib)*(c + id)=(ac - bd)+ i(ad + bc),
Division Rule: (a + ib)/(c + id)=((ac + bd)+ i(bc - ad))/(c2+ d2),
The complex conjugate of the complex number a + ib is given as a - ib,
The polar form of a complex number z = x + iy can be written as z = r cis 0, where r = Vx2+ y2 is the magnitude of the complex number, and 0 is the phase of z and
given as follows:
2arctan
(ifx>0,y0
if x <0, y =0
undefined
if x =0, y =0
(a)[14 points] Write the definition (a separate .h file) for a class called complex that has double point data mebers for storing real and imaginary parts. The two data part should be private. The class should at least define the following public member functions: i) to set the specified values in object, ii) to display complex number object, iii) Complex arithmetic operations defined on two complex numbers above and return a complex number iv) to conjugate a complex object. (Note that you may need to define additional methods.)
Write the corresponding source file (in a separate .cpp file) for your defined class. Consider all possible arithmetic operations given above, display styles as well as necessary outputs to produce (See the sample runs below.) You should have separate .h and .cpp for the defined complex class!
(b)[6 points] Write a C++ program (a separate .cpp file with a main () function) that uses the defined class in part (a) to produce the following outcomes. Note that you need ask the user to input two complex numbers to be stored as objects of your class. The data has to be private, hence only can be accessed within the class.

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_2

Step: 3

blur-text-image_3

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions