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:
and here is my second 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; do{ String theAmount = JOptionPane.showInputDialog("Loan Amount (Dollars & Cents):"); amount = Double.parseDouble(theAmount); } while(amount<1.00 || amount > 1000000.00); do{ String theLength = JOptionPane.showInputDialog("Loan Period - # of years:"); length = Integer.parseInt(theLength); } while(length<1 || length > 35); do{ 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); } }
it gives me a lot of errors. i know there's a lot wrong and i can't figure it out. any help? please?/** 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; System.out.printf("\n" + "%6f%14.2f%14.2f%14.2f%14.2f", c, (balance*iForMonth), principal, balance, totalInterest); System.out.println(); } } }