#include #include #include "complex.h" using namespace std; int main(){ // Construct 2 complex numbers Complex test1 = Complex(1,2); Complex test2 = Complex(3,4); cout


#include


#include


#include "complex.h"


using namespace std;


int main(){


// Construct 2 complex numbers


Complex test1 = Complex(1,2);


Complex test2 = Complex(3,4);


cout < "test1:="">


test1.print();


cout <>


cout < "test2:="">


test2.print();


cout <>


Complex addition = test1.add(test2);


cout <"add:>


addition.print();


cout <>


Complex multiplication = test1.multiply(test2);


cout <"multiply:>


multiplication.print();


cout <>


Complex division = test1.divide(test2);


cout <"divide:>


division.print();


cout <>


Complex conjugate_value = test1.conjugate();


cout <"complex conjugate:="">


conjugate_value.print(); cout <>


return 0;


}


Requirements<br>• Data members // a+bi<br>double real;// a<br>o double imag; // b<br>• Member functions:<br>Complex(double, double);<br>Complex add(Complex);<br>Complex multiply(Complex);<br>Complex divide(Complex);<br>Complex conjugate();<br>o void print(); // a+bi<br>Introduction to Computers II<br>3<br>

Extracted text: Requirements • Data members // a+bi double real;// a o double imag; // b • Member functions: Complex(double, double); Complex add(Complex); Complex multiply(Complex); Complex divide(Complex); Complex conjugate(); o void print(); // a+bi Introduction to Computers II 3
Complex Number<br>» Please upload complex.h and complex.cpp to<br>realize the Complex class.<br>» A complex number contains the real part and<br>the imaginary part, a+bi, where a and b are<br>real numbers and i=(-1)0.5 represents the<br>imaginary unit.<br>· Ex)<br>• (1+2i) + (3+4i) =<br>(1+2i) * (3+4i) = (-3+10i)<br>(4+6i)<br>Introduction to Computers II<br>2<br>

Extracted text: Complex Number » Please upload complex.h and complex.cpp to realize the Complex class. » A complex number contains the real part and the imaginary part, a+bi, where a and b are real numbers and i=(-1)0.5 represents the imaginary unit. · Ex) • (1+2i) + (3+4i) = (1+2i) * (3+4i) = (-3+10i) (4+6i) Introduction to Computers II 2

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here