Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for Compplex nummber in Eng. I need the Pseudocode list of this code: MAIN.CPP //Declaration of class Complex //defined in Complex.cpp #include #include

This is for Compplex nummber in Eng.

I need the Pseudocode list of this code:

MAIN.CPP

//Declaration of class Complex

//defined in Complex.cpp

#include

#include

#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 << "Author: Nauman Zubair ";

cout << "Initial Values ";

cout << "c1: ";

c1.print();

cout << setw(10) << "c2: ";

c2.print();

cout << " Assignment Operator c1 = c2" << setw(5);

c1 = c2;

cout << setw(17) << "c1: ";

c1.print();

cout << " Initial Values";

cout << " c3: ";

c3.print();

cout << setw(10) << "c4: ";

c4.print();

cout << " Overloaded + operator ";

Complex c5 = c3 + c4;

cout << "c4 + c3: ";

c5.print();

cout << " Overloaded - operator";

cout << " c4 - c3: ";

c5 = c4 - c3;

c5.print();

cout << " Overloaded * operator";

cout << " c3 * c4: ";

c5 = c3 * c4;

c5.print();

cout << " Overloaded / operator";

cout << " c3 / c4: ";

c5 = c3 / c4;

c5.print();

cout << " = ";

c3.print();

cout << " / ";

c4.print();

cout << " Overloaded || operator";

cout << " c1=c2||c3||c4: ";

c1 = c2||c3||c4;

c1.print();

cout << " = ";

c2.print();

cout << " || ";

c3.print();

cout << " || ";

c4.print();

cin.get();

cin.get();

}

Declaration of class Complex

Complex.h

#ifndef COMPLEX_H

#define COMPLEX_H

class Complex

{

public:

Complex(double, double);

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;

private:

double real;

double imaginary;

};

#endif // COMPLEX_H

Complex.cpp Function Definition

#include "Complex.h"

#include

#include

#include

using namespace std;

Complex::Complex( double realPart, double imaginaryPart )

: real ( realPart ), imaginary( imaginaryPart )

{}

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 ,

imaginary * operand2.real + real * operand2.imaginary );

}

Complex Complex::operator/( const Complex &operand2 ) const

{

return Complex( (real * operand2.real + imaginary * operand2.imaginary) /

(operand2.real * operand2.real + operand2.imaginary * operand2.imaginary),

(imaginary * operand2.real - real * operand2.imaginary)/

(operand2.real * operand2.real + operand2.imaginary * operand2.imaginary) );

}

Complex Complex::operator||( const Complex &operand2 ) const

{

return (*this * operand2)/(*this + operand2);

}

void Complex::print() const

{

cout << "(" << real << setprecision(2) << fixed << ",";

imaginary >= 0? cout << " j": cout << " -j";

cout << abs(imaginary) << setprecision(2) << fixed << ")";

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions