complextest

complextest - cout<<"The imaginary part of the...

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

/** @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;

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout<<"The imaginary part of the conjugate of z4 is "<<(z4.conjugate()).getImag()<<endl; cout<<"The angle of the conjugate of z4 is "<<(z4.conjugate()).angle()<<"."<<endl; cout<<"The magnitude of the conjugate of z4 is "<<(z4.conjugate()).magnitude()<<"."<<endl; cout<<"(z3*conj(z4))/(z4*conj(z4))= "; cout<<(z3*z4.conjugate())/(z4*z4.conjugate())<<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("The result of ((z1-z2)*(z3/z4))/(z4/z3) is %lf %lf.\n", 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<<"((z1-z2)x(z3/z4))/(z4/z3)"<<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

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern