
-----------------------------------
LOL123
Mon Mar 22, 2010 5:22 pm

Mortgage program
-----------------------------------
Hello I have to make a program that calculates when a presons mortgage will be paid off

A homeowner takes a mortgage for $120 000 at 10 3/4% per year. At the end of each year an amount of $24 000 is paid. Write a program to show how the mortgage is paid off, year by year until the mortagage is paid off.

Heres my code:

import java.io.*;
class mortgageproj
{
  public static void main (String args 

When the program is run it doesnt go down to zero it only does the calculations once? would I need to use a loop to make it keep repeating?

-----------------------------------
jbking
Mon Mar 22, 2010 5:43 pm

Re: Mortgage program
-----------------------------------
When the program is run it doesnt go down to zero it only does the calculations once? would I need to use a loop to make it keep repeating?

Have you traced the program to notice that you aren't telling it to repeat any instructions and thus it doesn't repeat anything?

Yes, a loop is a common way to make a program repeat, though not the only way as you could do recursive calls for another way to resolve the problem if you want a different approach.

-----------------------------------
LOL123
Mon Mar 22, 2010 6:57 pm

Re: Mortgage program
-----------------------------------
So do while loop would work right? 
How should I set it up
like this:
while mortgage > 0
do
all steps

is that correct?
