Let's review what we have done so far by working through a complete example.
You have made it through plebe year and your thoughts turn to your car loan. The problem is you have filet mignon tastes and a hotdog checkbook balance. Even with your loan, you know you will need to save some money between now and then to buy the car you really want.
So, letís write a program that reads in a user's first name, middle initial and last name, a monthly payment amount (in whole dollars), rate (annual interest rate), a duration (in years) and a target savings amount from the user, and then prints out the amount saved at the end of the duration (assuming monthly compounding) along with a message that says "first name the target is met - buy the car!" or "first name target not met - pick a cheaper car!" depending on whether the ending balance is greater than or equal to the target.
Two sample runs we can use to test our solution are
Sample Run 1
input> Mary J. Smith
Sample Run 2
input> John P. Jones
Design a working algorithm!!!!
Let's use RAPTOR to design our solution and make sure it works BEFORE we start coding. Click here to see the final flowchart.
Next, implement your RAPTOR design as C++ code.
But recognize the fact that input and output will be a little more detailed than the flowchart implies to get it to print exactly as the sample runs above. Click here for a final solution.
Last modified by LT M. Johnson 08/15/2007 10:53 AM