complextest

complextest - cout<<"The...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/** @file complextest.cpp @author Randall Paul Robert (9771) @date 2005-10-01 Description: program to test the complex class implementation Course: CS1254.02 Logon ID: cs125456 Lab #: 2 Instructor: William Duncan */ #include <iostream> #include "complex.h" #include <cstdlib> using namespace std; int main(int argc, char **argv) { Complex z1(4,-2); Complex z2(-4,2); Complex z3(-4,-3); Complex z4(3,-4); Complex z5; Complex z6; Complex z7; Complex z8; Complex z9; Complex z10; Complex z11; Complex z12; double ang; cout<<"z1 = "<<z1<<endl; cout<<"z2 = "<<z2<<endl; cout<<"z3 = "<<z3<<endl; cout<<"z4 = "<<z4<<endl; cout<<"z2 x z3 = "<<z2*z3<<endl; cout<<"z1 + z2 = "<<z1+z2<<endl; cout<<"z3 = "<<z3<<endl; cout<<"z4 = "<<z4<<endl; cout<<"z3-z4 = "<<z3-z4<<endl; cout<<"((z2+z3)x(z3-z4)) = "; cout<<(z2+z3)*(z3-z4)<<endl; cout<<"((z2+z3)x(z3-z4))/z3 = "; z6 = ((z2+z3)*(z3-z4))/z3; cout<<z6<<endl; cout<<"z3 / z4 = "<<(z3/z4)<<endl; cout<<"Conj(z4) = "<<z4.conjugate()<<endl; cout<<"The real part of the conjugate of z4 is "<<(z4.conjugate()).getReal()<<endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout&lt;&lt;&quot;The imaginary part of the conjugate of z4 is &quot;&lt;&lt;(z4.conjugate()).getImag()&lt;&lt;endl; cout&lt;&lt;&quot;The angle of the conjugate of z4 is &quot;&lt;&lt;(z4.conjugate()).angle()&lt;&lt;&quot;.&quot;&lt;&lt;endl; cout&lt;&lt;&quot;The magnitude of the conjugate of z4 is &quot;&lt;&lt;(z4.conjugate()).magnitude()&lt;&lt;&quot;.&quot;&lt;&lt;endl; cout&lt;&lt;&quot;(z3*conj(z4))/(z4*conj(z4))= &quot;; cout&lt;&lt;(z3*z4.conjugate())/(z4*z4.conjugate())&lt;&lt;endl; /* Add statement here to compute ((z1-z2).(z3/z4))/(z4/z3) and print the result:*/ z7 = DivCmplx(MulCmplx(SubCmplx(z1,z2),DivCmplx(z3,z4)),DivCmplx(z4/z3)); printf(&quot;The result of ((z1-z2)*(z3/z4))/(z4/z3) is %lf %lf.\n&quot;, RealPartCmplx(z7), ImagPartCmplx(z7)); z8 = (z3/z4); z9 = (z1-z2); z10 = (z8*z9); z11 = (z4/z3); z12 = (z10/z11); //((z1-z2).(z3/z4))/(z4/z3) cout&lt;&lt;&quot;((z1-z2)x(z3/z4))/(z4/z3)&quot;&lt;&lt;z12 ang = (z1+z2).angle(); /* Put a comment here explaining what happened and why? divide by zero. .. crash. .. i dont know??????/ */ return 0; }...
View Full Document

Page1 / 2

complextest - cout&amp;amp;lt;&amp;amp;lt;&amp;amp;quot;The...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online