Note for programmer: 1.Write a separate main() function as a driver for each question. The driver should demonstrate all the required functionalities of a question. 2. Write a c++ code and do not use any String or Math libraries (such as cmath, cstring, string, etc.) and also do not use built-in functions (such as pow, etc.)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Note for programmer:

1.Write a separate main() function as a driver for each question. The driver should demonstrate all the required functionalities of a question.

2. Write a c++ code and do not use any String or Math libraries (such as cmath, cstring, string, etc.) and also do not use built-in functions (such as pow, etc.).

Q1: Operator Overloading for Complex Numbers
Develop a class named Complex for representing complex numbers. A complex
number has the general form a + bi, where a is the real part and b is the imaginary
part (i stands for imaginary). Arithmetic operations on complex numbers are as
follows:
(a + bi) + (c + di) = (a + c) + (b + d) i
(a + bi) – (c + di) = (a – c) + (b d) i
(a + bi) * (c + di) = (ac – bd) + (ad + bc) i
(a + bi) / (c + di) = [(ac + bd) + (bc – ad) i]/ (c² + d?)
The class should also provide the following overloaded operator capabilities:
a. Overload the addition operator (+) to add two Complex numbers.
b. Overload the subtraction operator (-) to subtract two Complex numbers.
c. Overload the multiplication operator (*) to multiply two Complex numbers.
d. Overload the division operator (/) to divide two Complex numbers.
e. Overload the addition assignment operator (+=), subtraction assignment
operator (-=), multiplication assignment operator (*=), and division
assignment operator (/=).
f. Overload the assignment operator (=) to assign one Complex number to
another.
g. Overload the stream insertion (<<) to get the input Complex numbers and
stream extraction operator (>>) to display Complex numbers.
h. Overload the comparison operators
Complex numbers are equal or not.
i. Overload the comparison operators (<) and (>) to check whether one
Complex number is less or greater than the other.
and (!=) to check whether two
%3%3D
Define all overloaded operators (except for stream insertion <<' and stream
extraction >>' operators) as member functions of the Complex class. The
overloaded function for stream insertion (<<) and stream extraction (>>) operator
should be non-member friend functions. You need to write three files (complex.h,
complex.cpp, and complexMain.cpp).
Transcribed Image Text:Q1: Operator Overloading for Complex Numbers Develop a class named Complex for representing complex numbers. A complex number has the general form a + bi, where a is the real part and b is the imaginary part (i stands for imaginary). Arithmetic operations on complex numbers are as follows: (a + bi) + (c + di) = (a + c) + (b + d) i (a + bi) – (c + di) = (a – c) + (b d) i (a + bi) * (c + di) = (ac – bd) + (ad + bc) i (a + bi) / (c + di) = [(ac + bd) + (bc – ad) i]/ (c² + d?) The class should also provide the following overloaded operator capabilities: a. Overload the addition operator (+) to add two Complex numbers. b. Overload the subtraction operator (-) to subtract two Complex numbers. c. Overload the multiplication operator (*) to multiply two Complex numbers. d. Overload the division operator (/) to divide two Complex numbers. e. Overload the addition assignment operator (+=), subtraction assignment operator (-=), multiplication assignment operator (*=), and division assignment operator (/=). f. Overload the assignment operator (=) to assign one Complex number to another. g. Overload the stream insertion (<<) to get the input Complex numbers and stream extraction operator (>>) to display Complex numbers. h. Overload the comparison operators Complex numbers are equal or not. i. Overload the comparison operators (<) and (>) to check whether one Complex number is less or greater than the other. and (!=) to check whether two %3%3D Define all overloaded operators (except for stream insertion <<' and stream extraction >>' operators) as member functions of the Complex class. The overloaded function for stream insertion (<<) and stream extraction (>>) operator should be non-member friend functions. You need to write three files (complex.h, complex.cpp, and complexMain.cpp).
Expert Solution
steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY