Assignment 2c.  Buying a Racing Bike.

 

On January 1, 2012, Ralph bought his girlfriend Asha an excellent (and expensive) racing bike.  Its price was $1,426.80.  Ralph’s first payment will be on February 1, 2012. Ralph didn’t have that much money, but he made a down payment on the bike of $216.   He was charged a shipping fee of $28l.84 and an assembly fee of $184.56.  He agree to pay a monthly payment of $124.99 each month (except he will skip the third payment --- the March payment, when he is going to Florida.)  Of course, the final payment may be less than $99.99, due to the fact that the final amount owing will likely be less that $99.99.  He agrees to pay interest each month which is equal to 4.99% of the total amount he owing at the time (including the amounts of the shipping and assembly fees).

 

You to write a C++ program that prints out what Ralph pays and what he owes each month (up to paying off the entire amount owing).  You program should output the following (including the two initial lines).

Ralph pays for Asha’s Racing Bike

        Month     Interest      Payment  Tot Payment    Principle

            1        83.69       124.99       124.99      1635.90

            2        81.63       124.99       249.98      1592.54

            3        79.47         0.00       249.98      1672.01

            4        83.43       124.99       374.97      1630.46

          ...  ...  ... print actual numbers ...

           24        14.94       124.99      2874.77       189.30

           25         9.45       124.99      2999.76        73.76

           26         3.68        77.44      3077.20         0.00

Your C++ program should contain a single loop that cycles through each month and prints out this table.  Your program should have a main program and a function called headerLines that prints the top two lines.  It should also have a function called outputForMonth that accepts parameters for the month, interest, payment etc. and prints them out one line at a time (as in the example above).

 

Write your program so it is easy to read and understand it.  Choose identifiers that describe their use.   At the beginning of your program, define constants for any specific numbers, such as the rate of interest and the down payment.  Do not use any global constants or variables.

 

Your entire program should be in the file bike.cpp

 

Hint: To understand how to make the numbers come out in columns with two fractional digits (for example 45.16), see Savitch’s slides on printing precision in his Chapter 1 slide #32 and Buhr’s slide on example of “setw” (2.10.1.3 Formats).