Download presentation
Presentation is loading. Please wait.
Published byAnabel Wells Modified over 8 years ago
1
91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 *** Modification *** This assignment turned out to a bit harder than I wanted it to be. For this reason, I am simplifying it somewhat. If you wish, you may omit the “total payments” column from your table. You may also deal with the tricky cases (debt not paid off in a reasonable time, debt never gets paid off) by just putting “100” in the years to pay column. A sample executable which illustrates these changes has been posted. Keep in mind that this is an just option – students who wish to do the exercise as originally posted are of course welcome to do so. There is no penalty for choosing the simpler option and no bonus for doing the assignment as originally posted. We will of course be reasonable in marking the work of students who attempt the original assignment. No marks will be deducted for mistakes in the “extra” code required.
2
91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 2 Exercise 4 Suppose that you’re a student with a student loan and that you’re interested in knowing how much you’ll owe at graduation, and how long it will take you to pay this debt off. Suppose also that you’d like to know how much worse things will be if you slip up and bit (not, of course, in 166) and take more than four years to complete your degree. As you’re an expert C++ programmer, you decide to knock off a little program that will give you the information you want…. The sample program should give the idea. After entering the interest rate which is to be applied (negative to stop the program), the user enters the amount that is to be borrowed every year while studying, and the amount that is to be repaid every year afterwards. The program then produces a table summarizing the situation for study periods ranging from 4 to 10 years. Some points to note: 1/. During the study period, debt increases as follows: debt at end of year = (debt at start of year + loan amount) * (1 + rate/100) 2/. During the repayment period, debt decreases (hopefully) as follows: debt at end of year = ((debt at start of year) * (1 + rate / 100)) – payment amount 3/. When the last payment rolls around, you pay only what is required to wipe out the debt (i.e. the last payment may, and typically will, be smaller than the others). Keep this in mind when calculating the total amount paid. 4/. If the debt at graduation and/or the interest rate are high, or the repayment amount is small, the debt may never get paid off (i.e. the debt may just keep on growing, year after year). Be sure to somehow guard against this causing an infinite loop. One way to do this is to have your calculation loop terminate when either the debt has been paid off or some maximum number of years have gone by. In cases where the debt is not paid in a reasonable number of years (say, within 50 years), have your table include an appropriate message. For an example, try the sample program with 10% interest and $1000 loan and repayment amounts.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.