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

A complex number has the form a + b i , where a and b arereal numbers and i ² =

ID: 3612984 • Letter: A

Question

A complex number has the form a + bi, where a and b arereal numbers and

i² = -1. The four basic arithmeticoperations for complex numbers are defined as follows:

           addition:                      (a + bi)+(c + di) = (a + c)+(b + d)i

           subtraction:                  (a + bi)-(c + di) = (a - c)+(b - d)i

           multiplication:               (a + bi)*(c + di) = (ac – bd)+(ad +bc)i

           division:                       a + bi = (ac + bd) + (bc –ad) i

                  c + di   (c² + d²)   (c² + d²)

                                               provided   both c and d do not equal zero

(a)    Write a class to store complex numbers andprovide operations for the four basic arithmetic operations alongwith input and output operations. (You must have a class that hasattributes of a real and an imaginary part. You would have 2instances of this class for 2 complex numbers.) Use the time typeproject in your text to see help you with two class objectsinteracting.

(b)    Write a program to read two complexnumbers and a symbol for one of these operations and to perform theindicated operations.

(c)    Allow your program to continue until theuser decides to Quit.

Explanation / Answer

please rate - thanks sample run enter a complex number pair such as (5.1,2.3i):(5.1,2.3i) enter a complex number pair such as (5.1,2.3i):(5.1,2.3i) enter choice: (+)add, (-)sub, (*)mult, (/)divide:/ (1.00,0.00i) Are you done(Y/N)? n enter a complex number pair such as (5.1,2.3i):(5.1,2.3i) enter a complex number pair such as (5.1,2.3i):(7.2,3.6i) enter choice: (+)add, (-)sub, (*)mult, (/)divide:+ (12.30,5.90i) Are you done(Y/N)? y Press any key to continue . . . code #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