Programming questions 2

Anonymous
timer Asked: Mar 8th, 2019
account_balance_wallet $5

Question Description

Program Specifications: Congratulations! The "Mafiosa Bank of Uncle Sal" in Miami has accepted your application for a 20 year mortgage on your first home. You put $25,000 down on a $325K house and will be borrowing $300K (three hundred thousand) from the bank at an interest rate of 4.25%. The terms of the loan state that you only make one payment per year to the bank in December for an agreed upon amount. For the very last payment (year 20), you must pay the entire remaining amount due. You now realize this is not such a great deal, but you have signed the contract and until a lawyer gets you out of it, you are stuck.

So at the end of every calendar year, several things take place:

  1. The bank computes the interest based on what you currently owe.
  2. The bank adds the interest to the amount due resulting in the revised amount due.
  3. You make your agreed upon payment which reduces the total amount you owe.

Note: Yes, the bank computes the interest and adjusts the total amount owed before you make your payment (you know why don't you?).

In gathering information for your lawyer, you want to demonstrate how much you will have to pay at the end of your loan period of 20 years. To do this, you have to write a program that will read a variable "amount" from the keyboard that will be the agreed upon amount to pay yearly to the bank. Your program will then print the results of the calculations for each year as follows:

Example of input/output (you must have the same wording - only the amounts will change depending upon the payment):

Annual amount ($) ? 10000
At the end of year 1 Remaining due: 302750 Total interest: 12750 Total paid: 10000
At the end of year 2 Remaining due: 305616 Total interest: 25616 Total paid: 20000
At the end of year 3 Remaining due: etc.

...etc.

At the end of year 19 Remaining due: 377982 Total interest: 267982 Total paid: 190000
At the end of year 20 Remaining due: 394046 Total interest: 284046 Total paid: 584046

Program Requirements:

  1. Alignment - You do not have to have the output aligned exactly as above. It should simply be neat and easy to read. You must use the exact same wording as above.
  2. Constants - Your program must define the rate, duration of loan, and amount borrowed as class constants.
  3. Numeric Types - The calculations should be made with variable of an appropriate type - but you should output only dollars. Use casting to do that (there are ways to print double with appropriate number of decimals - we will see that later).
  4. Valid Data - You can assume the amount entered is a positive real number less than 23000.
  5. Style - Be sure to follow the guidelines of good style using proper indentation, well-chosen identifiers and appropriate use of comments.

TIPS:

  • Setting up your loop - In general with loops, the tricky part is the start of the loop and the end of the loop. Here obviously the result of the year 20 is *special* since the calculation is not the same as for other years. Because of this, you may want to loop for only 19 years and do the last year outside of the loop.
  • Testing your program - Submitting a program that has no syntax errors is not good enough for a perfect score. You need to start testing your programs for errors. Think of all cases where it is relatively easy to check if your program works properly. F for example:
    • What happens if the agreed upon amount to pay yearly is zero dollars?
    • What happens if the amount paid yearly is one dollar? A hundred dollars? Ten-thousand dollars?

Tutor Answer

KAUSHAL
School: Boston College

flag Report DMCA
Review

Anonymous
Thank you! Reasonably priced given the quality not just of the tutors but the moderators too. They were helpful and accommodating given my needs.

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors