i need some help with my assignment the link is to the assignment
Complex.h
#include <iostream>
using namespace std;
class Complex
{
private:
double realPart;
double imaginaryPart;
public:
//Default Constructor
Complex();
//Parameterized Constructor
Complex(double r, double i);
double GetRealPart() const;
double GetImaginaryPart() const;
void printComplex();
};
test.cpp
#include <iostream>
#include <complex>
using namespace std;
typedef complex<double> dcomplex;
int main(){
dcomplex a,b;
cout << "Enter real number: ";
cin >> a;
cout << "Enter imaginary number: ";
cin >> b;
cout << "a = " << a << "\n";
cout << "b = " << b << "\n";
cout << "a + b = " << a + b << "\n";
cout << "a * b = " << a * b << "\n";
cout << "a / b = " << a / b << "\n";
cout << "|a| = " << abs(a) << "\n";
cout << "complex conjugate of a = " << conj(a) << "\n";
cout << "norm of a = " << norm(a) << "\n";
cout << "abs of a = " << abs(a) << "\n";
cout << "exp(a) = " << exp(a) << "\n";
}
complex.cpp
#include <iostream>
#include "complex.h"
using namespace std;
Complex::Complex(double, double)
{
}
double Complex::GetRealPart( ) const
{
return realPart;
}
double Complex::GetImaginaryPart( ) const
{
return imaginaryPart;
}
void printComplexNumber( const Complex& n)
{
if( n.GetImaginaryPart ( ) < 0)
cout << n.GetRealPart( ) <<" - "<< n.GetImaginaryPart( ) << "i";
if( n.GetImaginaryPart( ) > 0)
cout << n.GetRealPart( ) <<" + "<< n.GetImaginaryPart( ) << "i";
if( n.GetImaginaryPart( ) > 0)
cout << n.GetRealPart( ) <<" * "<< n.GetImaginaryPart( ) << "i";
if( n.GetImaginaryPart( ) > 0)
cout << n.GetRealPart( ) <<" / "<< n.GetImaginaryPart( ) << "i";
if( n.GetRealPart( ) == 0)
cout << n.GetImaginaryPart( ) << "i";
if( n.GetImaginaryPart( ) == 0 )
cout << n.GetRealPart( );
if( n.GetImaginaryPart( ) == 1 )
cout << n.GetRealPart( ) << "i";
}