
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
c++
one of the image is what the output of the code is supposed to be.
please use these if possible:
#include <iostream>
using namespace std;
other stuff such as #include <conio.h> doesn't work on my compiler.
Please help me with this program. Thanks!

Transcribed Image Text:Classes and operator overloading
Define a class for complex numbers. A complex number is a number of the
form:
a + b*i where
for
purposes,
and b are numbers
of type
our
a
double
and i is a number that represents the quantity v-1 (i * i = -1).
Represent
a complex number
two
values
of
type double.
Name
the
as
member variables real and imaginary. (The variable for the number that
is multiplied by i
is
the
called imaginary.)
Call
the
class
one
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
constructor
that
has
only a single parameter
of
type
a
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:
(а + b*i)-(с+d*i) %3
(а-с)+ (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 Cl and C2.
Add, subtract and multiply C3 and C4.
Use the overloaded « to display the result of the three operations
as follow:

Transcribed Image Text:7*i)
7*i)
|(1 + 4*i) + (-3
|(1 + 4*i)
|(1 + 4*i) * (-3 - 7*i)
(4*i) + (-3 + i)
(4*i)
|(4*i)
-2
3*i
%3D
(-3
4 + 11*i
-
%3D
25
19*i
-3 + 5*i
%3D
(-3 + i)
(-3 + i)
3 + 3*i
=
-4
12*i
%3D
||
||
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 5 steps with 4 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- A(n) ____________ is one instance or variable of a class.arrow_forwardChapter 10 defined the class circleType to implement the basic properties of a circle. (Add the function print to this class to output the radius, area, and circumference of a circle.) Now every cylinder has a base and height, where the base is a circle. Design a class cylinderType that can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class circleType designed in Chapter 10. Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base, and set the center of the base. Also, write a program to test various operations on a cylinder.arrow_forwardConsider the definition of the class product Type as given in Exercise 8. Which function members are accessors and which are mutators? (4)arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,

C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning

EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT

C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr

Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage

Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,