Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Loan Payments

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Default Loan Payments

    i have to make a table that has the payment number (1,2,3,4....), interest, principle, unpaid balance, total interest to date, and have them print the data in vertical columns. we need to use two classes. here is my main class:

    /** Program: LoanInfoEntry
     * File Name: LoanInfoEntry.java
     * Author: Clara Merriman
     * Date: 4/6/2011
     * Description: receive input and run other class
    package lab09;
    import javax.swing.*;
     * @author Clara.Merriman
    public class LoanInfoEntry {
        public static void main(String[] args) {
        double amount;
        int length;
        double rate;
                String theAmount = JOptionPane.showInputDialog("Loan Amount (Dollars & Cents):");
                amount = Double.parseDouble(theAmount);
            while(amount<1.00 || amount > 1000000.00);
                String theLength = JOptionPane.showInputDialog("Loan Period - # of years:");
                length = Integer.parseInt(theLength);
            while(length<1 || length > 35);
                String theRate = JOptionPane.showInputDialog("Annual Interest Rate (e.g. 9.5):");
                rate = Double.parseDouble(theRate);
            while(rate<1.0 || rate>30.0);
            LoanPaymentSchedule pSchedule = new LoanPaymentSchedule();
            pSchedule.displayTable(amount, length, rate);
    and here is my second class:

    /** Program: LoanPaymentSchedule
     * File Name: LoanPaymentSchedule.java
     * Author: Clara Merriman
     * Date: 4/6/2011
     * Description: reflects monthly payments for a load
    package lab09;
    /**double balance = amount
     * double totalInterest = 0
     * double interestNow - balance *iForMonth
     * double principal = mPayment - interestNow
     * balance = balance - principal
     * totalInterest = totalInterest + interestNow
     * @author Clara.Merriman
    public class LoanPaymentSchedule {
        double amount;
        int length;
        double rate;
        double mPayment;
        double iForMonth;
        int nOfPayments;
        double interest;
        int months;
        double totalInterest = 0;
        double balance = amount;
        double principal;
    public void displayTable(double a, int b, double c){
        amount = a;
        length = b;
        rate = c;
        interest = rate/100.0;
        months = length*12;
        mPayment = (amount*interest)/(1.0-Math.pow((1.0/(1.0+interest)), months));
        iForMonth = interest/12;
        System.out.print("Payment # \t Interest \t Principle \t Unpaid Balance \t Total Interest to Date");
        for(int i = 1; i<=months; i++){
            principal = mPayment - (balance*iForMonth);
            balance = balance - principal;
            totalInterest = totalInterest+iForMonth;
                    + "%6f%14.2f%14.2f%14.2f%14.2f", c, (balance*iForMonth), principal, balance, totalInterest);
    it gives me a lot of errors. i know there's a lot wrong and i can't figure it out. any help? please?

  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    United Kingdom
    My Mood
    Thanked 287 Times in 225 Posts
    Blog Entries

    Default Re: Loan Payments

    Hello clarafeb1. Welcome to the Java Programming Forums.

    What are the errors exactly? I have compiled your code and it runs fine.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. savings and loan society
    By 5723 in forum Java Theory & Questions
    Replies: 9
    Last Post: November 13th, 2009, 11:01 PM

Tags for this Thread