Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need code that works in repl.it in main.cpp ** Complex Numbers ** Write a class for a complex number ADT. To refresh your memory,

I need code that works in repl.it in main.cpp

** Complex Numbers **

Write a class for a complex number ADT. To refresh your memory, complex numbers have the form: a+ bi. Where ais the real part, bis the imaginary part, and i represents the square root of -1(which doesn't exist and is therefore imaginary).

Standard mathematical operations are defined on complex numbers:

 

a+bi + c+di = (a+c) + (b+d)i

a+bi - c+di = (a-c) + (b-d)i

a+bi * c+di = (a*c-b*d) + (a*d+b*c)i // i*i == -1

(a*c+b*d) - (a*d-b*c)i

a+bi / c+di = ----------------------

c*c + d*d

-(a+bi) = (-a) + (-b)i

That last one is negation (aka opposite), of course.

And special operations are also defined:

 

|a+bi| = \/ a*a + b*b // magnitude

____

a+bi = a-bi // conjugate

Define these operations (along with constructors, input/output, and accessors/mutators) for your ADT/class. Place your ADT in a library.

Write a driver to test the ADT behaviors thoroughly.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago