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

the three files i have are -----complex.h----- #ifndef COMPLEX_H #define COMPLEX

ID: 656601 • Letter: T

Question

the three files i have are

-----complex.h-----

#ifndef COMPLEX_H
#define COMPLEX_H

class Complex
{
public:
Complex(double = 0.0 , double = 0.0);

// Complex operator=(const Complex &);
Complex operator+(const Complex & ) const;
Complex operator-(const Complex & ) const;
Complex operator*(const Complex & ) const;
Complex operator/(const Complex & ) const;
Complex operator||(const Complex & ) const;
void print() const;
protected:
private:
double real;
double imaginary;

};

#endif

-----complex.cpp-----

#include <iostream>
#include "Complex.h"
using namespace std;

Complex::Complex( double realPart, double imaginaryPart)
: real( realPart ),
imaginary( imaginaryPart )
{
// empty body
} // end Complex constructor

Complex Complex::operator+( const Complex &operand2) const
{
return Complex( real + operand2.real,
imaginary + operand2.imaginary);
}

Complex Complex::operator-( const Complex &operand2) const
{
return Complex( real - operand2.real,
imaginary - operand2.imaginary);
}
Complex Complex::operator*( const Complex &operand2) const
{
return Complex( real * operand2.real,
imaginary * operand2.imaginary);
}
Complex Complex::operator/( const Complex &operand2) const
{
return Complex( real / operand2.real,
imaginary / operand2.imaginary);
}
Complex Complex::operator||( const Complex &operand2) const
{
return Complex( real || operand2.real,
imaginary || operand2.imaginary);
}


void Complex::print() const
{
cout << '(' << real << ", " << imaginary << ')';
}

------Complextest-----

#include <iostream>
#include "Complex.h"
using namespace std;

int main()
{
Complex c1(0,0);
Complex c2(1,2);
Complex c3(8,2);
Complex c4(5,-3);

cout << "HW#8 Complex Numbers in Engineering";
cout << endl;
cout << "Author: ";
cout << endl;
cout << "Initial Values" << endl;
cout << "c1: ";
c1.print();
cout << " c2: ";
c2.print();

c1 = c2;
cout << " Assignment operator";
cout << " c1 = c2";
cout << " c1: ";
c1.print();
cout << endl;

cout << "Initial Values" << endl;
cout << "c3: ";
c3.print();
cout << " c4: ";
c4.print();

c1 = c4+c3;
cout << " Overloaded + operator" << endl;
cout << "c4 + c3: ";
c1.print();

c1 = c4-c3;
cout << " Overloaded - operator" << endl;
cout << "c4 - c3: ";
c1.print();

c1 = c4*c3;
cout << " Overloaded x operator" << endl;
cout << "c4 x c3: ";
c1.print();

c1 = c3/c4;
cout << " Overloaded / operator" << endl;
cout << "c3 / c4: ";
c1.print();
cout << " = ";
c3.print();
cout << " / ";
c4.print();

c1 = c4||c3;
cout << " Overloaded || operator" << endl;
cout << "c1 = c2||c3||c4: ";
c1.print();
cout << " = ";
c2.print();
cout << " || ";
c3.print();
cout << " || ";
c4.print();

cin.get();
cin.get();
return 0;
}

C:SchooNCSC11205ProjectsLion2inDebugLion2.exe Hu#8 Complex Numbers in Engineering Author Dr. Jeffery Gray Initial Ualues c1: (0.00, j0.00) Assignment operator c2: (1.00, j2.00) c1: (1.00, j2.00) c4: (5.00, -j3.00) Initial Ualues c3: (8.00, j2.00) ver oaded operator c4 + c3: (13.00, j1.00) Overloaded-operator c4 - c3: (-3.00, -j5.00) Overloaded* operator Overloaded / operator c3 / cH: (1.00, j1.00) (8.00, j2.00) / (5.00, -j3.00) Overloaded | I operator

Explanation / Answer

-----complex.h-----

#ifndef COMPLEX_H
#define COMPLEX_H

class Complex
{
public:
Complex(double = 0.0 , double = 0.0);

// Complex operator=(const Complex &);
Complex operator+(const Complex & ) const;
Complex operator-(const Complex & ) const;
Complex operator*(const Complex & ) const;
Complex operator/(const Complex & ) const;
Complex operator||(const Complex & ) const;
void print() const;
protected:
private:
double real;
double imaginary;

};

#endif

-----complex.cpp-----

#include <iostream>
#include "Complex.h"
using namespace std;

Complex::Complex( double realPart, double imaginaryPart)
: real( realPart ),
imaginary( imaginaryPart )
{
// empty body
} // end Complex constructor

Complex Complex::operator+( const Complex &operand2) const
{
return Complex( real + operand2.real,
imaginary + operand2.imaginary);
}

Complex Complex::operator-( const Complex &operand2) const
{
return Complex( real - operand2.real,
imaginary - operand2.imaginary);
}
Complex Complex::operator*( const Complex &operand2) const
{
return Complex( real * operand2.real,
imaginary * operand2.imaginary);
}
Complex Complex::operator/( const Complex &operand2) const
{
return Complex( real / operand2.real,
imaginary / operand2.imaginary);
}
Complex Complex::operator||( const Complex &operand2) const
{
return Complex( real || operand2.real,
imaginary || operand2.imaginary);
}


void Complex::print() const
{
cout << '(' << real << ", " << imaginary << ')';
}

------Complextest-----

#include <iostream>
#include "Complex.h"
using namespace std;

int main()
{
Complex c1(0,0);
Complex c2(1,2);
Complex c3(8,2);
Complex c4(5,-3);

cout << "HW#8 Complex Numbers in Engineering";
cout << endl;
cout << "Author: ";
cout<<"Dr. Jeffery Gray";
cout << endl;
cout << "Initial Values" << endl;
cout << "c1: ";
c1.print();
cout << " c2: ";
c2.print();

c1 = c2;
cout << " Assignment operator";
cout << " c1 = c2";
cout << " c1: ";
c1.print();
cout << endl;

cout << "Initial Values" << endl;
cout << "c3: ";
c3.print();
cout << " c4: ";
c4.print();

c1 = c4+c3;
cout << " Overloaded + operator" << endl;
cout << "c4 + c3: ";
c1.print();

c1 = c4-c3;
cout << " Overloaded - operator" << endl;
cout << "c4 - c3: ";
c1.print();

c1 = c4*c3;
cout << " Overloaded x operator" << endl;
cout << "c4 x c3: ";
c1.print();

c1 = c3/c4;
cout << " Overloaded / operator" << endl;
cout << "c3 / c4: ";
c1.print();
cout << " = ";
c3.print();
cout << " / ";
c4.print();

c1 = c4||c3;
cout << " Overloaded || operator" << endl;
cout << "c1 = c2||c3||c4: ";
c1.print();
cout << " = ";
c2.print();
cout << " || ";
c3.print();
cout << " || ";
c4.print();

cin.get();
cin.get();
return 0;
}