Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
u*w = (x*a - y*b) + i*(x*b + y*a)
In other words the real part of the product u*v is (x*a - y*b), and the imaginary part is (x*b + y*a).Do one or the other of the versions of Problem 1 described below. You do not need to do both! The 90% solution is simpler to do (though more tedious and less interesting) and only worth at most 90 points. The 100% is a bit tougher (though less tedious and more interesting) and is worth 100 points. Most important to me is that I get a working program from you.
Remember: plan out the basic steps of your program before you start with the actual code. Also, look at the example problems at the end of the class notes. Seeing how they work will help you design your own solution.
| A 90% Solution | A 100% Solution |
Write a program that reads in two complex numbers
and prints out their product.
A typical session with the program
might look like this (user input is in red):
Enter the real part of u : 3 Enter the complex part of u: 4 Enter the real part of w : -0.5 Enter the complex part of w: .25 (3 + i*4) * (-0.5 + i*0.25) = -2.5 + i*-1.25 |
Write a program that reads in a complex number from the user
and prints out its cube - i.e. it reads in a complex number
w and prints out w^3. A typical session with the program
might look like this (user input is in red):
Enter the real part of w : -1.2 Enter the complex part of w: 1.3 (-1.2 + i*1.3)^3 = 4.356 + i*3.419Note: I do not want you to derive a single mathematical expression for the cube of a complex number, which is a very ugly expression, and use that in your code. Cubing means multiplying twice. Use that! |
Turn in a printout of the source code for your program (which should have your name and alpha in a comment at the top), a screen capture of the window showing your program running with the above input, and a printout of this page with name, alpha, help-info filled in. These should be stapled together.
A note about using the Internet to complete this homework: You may be tempted to google how to do complex numbers with c++ and come across the complex library. You should not be using this library because the point of the assignment is to complete it using the skills you currently have based on the lessons so far; which means variable assignments and arithmetic expressions and nothing else. The purpose of this homework is for you exercise those skills and not the skill of googling for solutions that have not been covered in class.
codprint followed by
the names of the .cpp (or .h) files you want to print.
For example, if I have files foo.cpp and bar.cpp I
would give the command
codeprint foo.cpp bar.cpp
Note: Shift+PrintScreen does the screencapture within the VM. This means that the resulting .png file (which you name yourself) should be dragged outof the VM desktop and onto the Windows desktop to print.
out.pdf which you can then print
out in whatever way works best for you. I recommend
you click on the folder icon along the right-hand side
of your VM's desktop, navigate to the right directory,
and drag out.pdf of the VM desktop and onto your
Windows desktop.