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

Consider the class given below for representing complex numbers and implementing

ID: 3582591 • Letter: C

Question

Consider the class given below for representing complex numbers and implementing different operations using complex numbers. Read and analyze the code carefully and answer the following questions: (a) Write C++ for the member function div that is used for dividing two complex numbers. Hint: Result of dividing any two complex numbers, say (a ib/(c id can be written in the form (x i), where r and,y each can be expressed in terms of a, b, c and d (b) Write a main program that creates three complex objects alpha (initialized to 3 i4), beta (initialized to 5-12) and gamma (uninitialized). It then calls the div function to divide alpha by beta and stores the result in gamma. class complex private: float real; float imag public: complex complex (float, float); void read void print complex add (const complexs) complex mult (const complex6) this function complex div (const complex6) 11 write c++ code for complex complex (float re, float im) real re imag im; void complex read cout enter real and imaginary parts endl: cin real imag; void complex print cout real real imaginary imag endl;

Explanation / Answer

//In this function we will do the required checking and updates public void update() { move(); } //This function will move the player according to its direction public void move(){ if(left){ x--; }if(right){ x++; }if(up){ y--; }if(down){ y++; } }