Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 20th, 2005, 4:27 PM   #1
rockybalboa
Newbie
 
Join Date: Mar 2005
Posts: 1
Rep Power: 0 rockybalboa is on a distinguished road
Can't get loop to work

Hello,
Can anyone advise me on why I can't get the following code to loop? I'm trying to get continuous calculation until the variable amount = 0.
I will work out display params after I get the loop to work. I'm new to Java, but not coding. This is a simple program so there's probably a simple answer.
My thanks to anyone willing to teach me.
Thanks
DW

import java.text.*;

class Wk3
{
    public static void main (String[] arguments)    //create main
    {
        int term = 30;                              //init var for length of loan
        double amount = 200000;                        //init var for loan amt
        double pmt = 0;                             //init var for payment
        double rate = .0575;                        //init var for interest rate
        double rateMo = 0;                          //init var for monthly interest paid        
        {
            rate = (rate/12);                       //divide annual rate to get monthly rate
            term = (term * 12);                     //multiply years to get length in months            
            pmt= (amount * (rate)) / (1-Math.pow(1 + rate, - term));    //compute payment
            {
                if (amount > 0)                         //run if counter >0
                {
                    java.text.DecimalFormat dec = new java.text.DecimalFormat(",###.00");               //format next output to dollars.cents
                    System.out.println("\nThis months payment is $" + dec.format (pmt));                //display payment
                    System.out.println ("\nYour loan balance is $" + dec.format (amount));              //display loan amt
                    System.out.println("\nThis months interest is $" + dec.format (amount * (rate )));  //montly interest payment
                }
                amount -=  pmt;
            }
        }
    }
}
rockybalboa is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC