Write a C++ program using the operator overloading concept and display its results. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Consider a class named Complex with the private member variables.

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

OUTPUT MUST MATCH AS IT IS 

----------------------------------

Write a C++ program using the operator overloading concept and display its results.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

Consider a class named Complex with the private member variables.

Datatype Variable
int real
int imaginary

Include the private member variables and the constructor in the class Complex.

Define the following public methods in the class Complex.

Method Name Description
Complex operator+(Complex a2) This function is used to perform the additional operation of
the two complex numbers and returns the result.
Complex operator-(Complex a2) This function is used to perform the subtraction operation of
the two complex numbers and returns the result.
complex operator*(complex a2) This function is used to perform the multiplication operation of
the two complex numbers and returns the result.
complex operator/(complex a2) This function is used to perform the division operation of
the two complex numbers and returns the result.
void display() This function is used to display the complex numbers

 

In the main method get the inputs from the user and performs the operator overloading concept.
 

Input and Output Format :
Refer to sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.
Sample Input and Output 1 :

1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :

Enter The First Complex Number:
Enter Real Part:
5
Enter Imaginary Part:
2
Complex number is = 5+2i
Enter The Second Complex Number:
Enter Real Part:
4
Enter Imaginary Part:
1
Complex number is = 4+1i
Addition of two Complex number is = 9+3i
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :
3
Enter The First Complex Number:
Enter Real Part:
4
Enter Imaginary Part:
3
Complex number is = 4+3i
Enter The Second Complex Number:
Enter Real Part:
5
Enter Imaginary Part:
2
Complex number is = 5+2i
Multiplication of two Complex number is = 14+23i
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :
5
 

Sample Input and Output 2 :

1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :
2
Enter The First Complex Number:
Enter Real Part:
6
Enter Imaginary Part:
3
Complex number is = 6+3i
Enter The Second Complex Number:
Enter Real Part:
4
Enter Imaginary Part:
2
Complex number is = 4+2i
Subtraction of two Complex number is = 2+1i
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :
4
Enter The First Complex Number:
Enter Real Part:
6
Enter Imaginary Part:
3
Complex number is = 6+3i
Enter The Second Complex Number:
Enter Real Part:
4
Enter Imaginary Part:
1
Complex number is = 4+1i
Division of two Complex number is = 1+0i
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Exit
Enter the choice :
5

Expert Solution
steps

Step by step

Solved in 4 steps with 2 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