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

Write a class definition for a complex number. The class definition should inclu

ID: 3613630 • Letter: W

Question

Write a class definition for a complex number.

The class definition should include variables that represent thereal and imaginary part of the number.

You should include a constructor that allows you to specify thereal and imaginary parts and a default constructor.

You should also include functions that allow you to add, substract,multiply and divide two complex numbers. The functions return typeshould be complex number.

Also include a function called toString which displays the complexnumber.
THIS IS WHAT I GOT SO FAR PLEASE HELP !!!!!WILL RATELIFESAVER!!
 #include <iostream>using namespace std;class ComplexNumber {public:ComplexNumber();ComplexNumber(double inputreal,double inputimaginary);ComplexNumber add(ComplexNumber input);ComplexNumber subtract(ComplexNumber input);ComplexNumber multiply(ComplexNumber input);ComplexNumber divide(ComplexNumber input);void toString();private:double real;double imaginary;}int main() {ComplexNumber number1 = ComplexNumber(1,2);ComplexNumber number2 = ComplexNumber(3,4);ComplexNumber sum = number1.add(number2);ComplexNumber difference = number1.subtract(number2);ComplexNumber product = number1.multiply(number2);ComplexNumber quotient = number1.divide(number2);sum.toString();difference.toString();product.toString();quotient.toString();return(0);}
Write a class definition for a complex number.

The class definition should include variables that represent thereal and imaginary part of the number.

You should include a constructor that allows you to specify thereal and imaginary parts and a default constructor.

You should also include functions that allow you to add, substract,multiply and divide two complex numbers. The functions return typeshould be complex number.

Also include a function called toString which displays the complexnumber.
THIS IS WHAT I GOT SO FAR PLEASE HELP !!!!!WILL RATELIFESAVER!!
 #include <iostream>using namespace std;class ComplexNumber {public:ComplexNumber();ComplexNumber(double inputreal,double inputimaginary);ComplexNumber add(ComplexNumber input);ComplexNumber subtract(ComplexNumber input);ComplexNumber multiply(ComplexNumber input);ComplexNumber divide(ComplexNumber input);void toString();private:double real;double imaginary;}int main() {ComplexNumber number1 = ComplexNumber(1,2);ComplexNumber number2 = ComplexNumber(3,4);ComplexNumber sum = number1.add(number2);ComplexNumber difference = number1.subtract(number2);ComplexNumber product = number1.multiply(number2);ComplexNumber quotient = number1.divide(number2);sum.toString();difference.toString();product.toString();quotient.toString();return(0);}

Explanation / Answer

please rate - thanks Hope this should get you started--message me if you need morehelp #include #include using namespace std; class Complex {public: void Inputc(); void Outputc(); Complex operator+(Complex x); Complex operator-(Complex x); Complex operator*(Complex x); Complex operator/(Complex x); private: float real,imag; }; Complex Complex::operator + (Complex x) {Complex temp; temp.real=real+x.real; temp.imag=imag+x.imag; return(temp);} Complex Complex::operator - (Complex x) {Complex temp; temp.real=real-x.real; temp.imag=imag-x.imag; return(temp);} Complex Complex::operator *(Complex x) {Complex temp; temp.real=(real*x.real)-(imag*x.imag); temp.imag=(imag*x.real)+(real*x.imag); return(temp);} Complex Complex::operator / (Complex x) {Complex temp; temp.real=((real*x.real)+(imag*x.imag))/(x.real*x.real+x.imag*x.imag); temp.imag=((imag*x.real)-(real*x.imag))/(x.real*x.real+x.imag*x.imag); return(temp);} void Complex::Inputc(void) {char i,paren,comma,trash; cin>>paren>>real>>comma>>imag>>i>>paren; } void Complex::Outputc(void) {cout
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