Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with this question please.. thanks a lot in advance.. Task 2

ID: 3812986 • Letter: C

Question


Can someone help me with this question please.. thanks a lot in advance..

Task 2. class complex A complex number is any number a bi, where a is the real part, and b is the inaginary part. The addition of two conple numbers is given as The subtraction of two complex number is given as atbi The multiplication of two complex numbers is given as: c di ac-bd bo-adl i The division of two complex numbers is given as: conjugate of a complex numbe bi is given You are required to define a class named Complex for complex numbers The real part and imaginary part are two private double variables. Define five public member functions complex add Complex x), complex subtract Complex x l r complex multiply (Conplex x Complex divide (Complex and complex conjugate so that we can perform the operations on complex You will also define umbers other member functions, such as setting the value of a complex number, printing the complex numbers. The class complex is declared in the file complex main function defined in the file lab10ta sk2.cpp need to define the member functions of class Complex in the file Complex. cpp You submit only the file complex opp The output of the program is given below: value of x1 1, 2+2.3i The value of x2 is 3.4+4.5i 3 x1 x2 4.6+6.8i x4 x1 x2 2.2-2.2i x5 x3 x2 14.96+43.82i x6 x3 2 1.45363+0.076a767 i Change x6 to its conjugate. s 0768767 i

Explanation / Answer

#include <iostream>
using namespace std;




class complex
{
int i,r;
public:
void read()
{
cout<<" Enter Real Part:";
cin>>r;
cout<<"Enter Imaginary Part:";
cin>>i;
}
void display()
{
cout<<" = "<<r<<"+"<<i<<"i";
}
complex operator+(complex a2)
{
complex a;
a.r=r+a2.r;
a.i=i+a2.i;
cout<< "Addition =";cout<<endl;
return a;
}
complex operator-(complex a2)
{
complex a;
a.r=r-a2.r;
a.i=i-a2.i;
cout<< "Subtrction =";cout<<endl;
return a;
}
complex operator*(complex a2)
{
complex a;
a.r=(r*a2.r)-(i*a2.i);
a.i=(r*a2.i)+(i*a2.r);
cout<< "Multiplication =";cout<<endl;
return a;
}
complex operator/(complex a2)
{
complex a;
a.r=((r*a2.r)+(i*a2.i))/((a2.r*a2.r)+(a2.i*a2.i));
a.i=((i*a2.r)-(r*a2.i))/((a2.r*a2.r)+(a2.i*a2.i));
cout<< "Division =";cout<<endl;
return a;
}
};
int main()
{
int ch;

complex a,b,c;
  

cout<<" Enter The First Complex Number:";
a.read();
a.display();
cout<<" Enter The Second Complex Number:";
b.read();
b.display();
c=a+b;
c.display();
c=a-b;
c.display();
c=a*b;
c.display();
c=a/b;
c.display();

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote