CMIS 140 Foster (not DE!) Due: 11 Nov. Write a program to keep track of how much money you owe after each payment on a loan. As an example, suppose you start out on day 1 with a loan of $1000 at an annual percentage rate of 10%, compounded daily. Suppose you make your first payment of $500 on day 30. The amount you owe after applying your payment is computed as follows: - The daily interest rate is 10% / 365 days = 0.0274 % per day - On day 2, you owe $1000 + ($1000 * 0.0274 %) = $1000.27 - On day 3, you owe $1000.27 + ($1000.27 * 0.0274 %) = $1000.55 - .. - On day 30, you compute the interest before applying the payment (of course!). You owe $1007.70 from day 29. Now on day 30 before the payment, you owe $1007.07 + ($1007.07 * 0.0274 %) = $1007.97. - Then you apply the payment of $500. You now owe $507.97. The program will report that after applying the payment on day 30, you owe $507.97. Now you could apply another payment on or after day 30, and the program would tell you how much you owed after that payment. SPECIFICATION Your program will input the initial loan amount. It will then ask if you are a regular customer (R) or a preferred customer (P). Regular customers get an annual percentage rate (APR) of 10%; preferred customers get an APR of 8%. This will determine the daily percentage rate for the duration of the loan. The program should then accept payments until the loan is paid in full, and then report: - How many payments it took to pay the loan - Total interest that was paid - Any money returned from the final payment if you overpaid ERROR CHECKING - Ensure that the initial amount of the loan is positive - Ensure that user enters preferred or regular customer correctly - Ensure that the payment amount is positive - Ensure that the current payment is being applied on or after the day the last payment was applied HINTS - Display the monetary float values with two digits after the decimal point. - The user input error checking should be loops until the user enters valid value(s). Don't ever give a user just one chance to correct a mistake. - The interest is compounded daily, so calculating one day's interest and multiplying that by the number of days to the next payment will NOT give the correct interest accrued. SAMPLE OUTPUT This output does not need to be followed exactly. It is a guide. User input is in < > (The angle brackets are not typed by the user, they are here for illustration purposes). ----------------------------------------------------------------- Welcome to the program to check TrustUs Student Loans, Inc. Enter the initial amount for the loan, then each payment as directed. The software will compute the balance remaining after each payment. Enter the amount of the loan: <1000> Are you a regular customer (r) or a preferred customer (p)? You must enter 'r' for regular or 'p' for preferred. Are you a regular customer (r) or a preferred customer (p)? The interest rate is 10% APR compounded daily, or 0.02740% daily. On day#1, you owe $1000.00. For payment #1, enter the day on which you will pay and the payment amount. <30 -100> ERROR: Your payment amount must be positive. For payment #1, enter the day on which you will pay and the payment amount. <30 500> On day#30, you owe $507.97. For payment #2, enter the day on which you will pay and the payment amount. <15 500> ERROR: You must apply a payment on or after day #30. For payment #2, enter the day on which you will pay and the payment amount. <60 500> On day#60, you owe $12.17. For payment #3, enter the day on which you will pay and the payment amount. <90 500> $487.73 of your final payment will be returned after covering the remaining balance of your loan. You paid off your loan after 90 days in 3 payments. You paid $12.27 in interest. -------------------------------------------- EXAMPLE TEST CASES - For a regular customer with an initial loan amount of $1000, apply payments of $500 on day 30, day 60, and day 90. - For a preferred customer with an initial loan amount of $456.78 apply payments of $159.98 on day 30, day 35, and day 90. - Show the program correctly handling all error checking cases above. ----------------------------------------------------------------- TURN IN: - printed source code .cpp file -diskette with the source file You must use switch, do, and for statements as appropriate.