QUESTION PROVIDED BELOWKINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.   AND FOLLOW TEMPLATES PROVIDED AT END OF QUESTION CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , COMPLEX.cpp  ) ----------------- TEMPLATES BELOW FOR SOLUTION ----------------------- 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   ------------------------QUESTION ENDS---------------   --------------TEMPLATES BELOW--------------- main.cpp #include #include "Complex.cpp" using namespace std; int main() { //Fill your code here return 0; }   complex.cpp #include using namespace std; class Complex { //Fill your code here public: Complex operator+(Complex a2){ //Fill your code here } Complex operator-(Complex a2){ //Fill your code here } Complex operator*(Complex a2){ //Fill your code here } Complex operator/(Complex a2){ //Fill your code here } void display() { //Fill your code here } };

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

QUESTION PROVIDED BELOWKINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.

 

AND FOLLOW TEMPLATES PROVIDED AT END OF QUESTION CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , COMPLEX.cpp  )

----------------- TEMPLATES BELOW FOR SOLUTION -----------------------

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

 

------------------------QUESTION ENDS---------------

 

--------------TEMPLATES BELOW---------------

main.cpp

#include<iostream>
#include "Complex.cpp"
using namespace std;
int main()
{
//Fill your code here
return 0;
}

 

complex.cpp

#include<iostream>
using namespace std;

class Complex
{
//Fill your code here

public:
Complex operator+(Complex a2){
//Fill your code here
}

Complex operator-(Complex a2){
//Fill your code here
}

Complex operator*(Complex a2){
//Fill your code here
}

Complex operator/(Complex a2){
//Fill your code here
}
void display() {
//Fill your code here
}
};

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
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