I'm scratching my head on this one..can't figure out what I'm doing wrong.
This what I'm getting from Textpad:
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:19: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
LoanOptionsWk5[] Loans = new LoanOptionsWk5[3];//array setup for loans
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:19: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
LoanOptionsWk5[] Loans = new LoanOptionsWk5[3];//array setup for loans
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:21: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[0] = new LoanOptionsWk5 (200000, 7, .0525);//first loan @ 200000 over 7 years at 5.25 intrest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:22: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[1] = new LoanOptionsWk5 (200000, 15, .0550);//second loan @ 20000 over 15 years at 5.5 interest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:23: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[2] = new LoanOptionsWk5 (200000, 30, .0575);//third loan @ 20000 over 30 years at 5.75 interest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:77: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[c] = new LoanOptionsWk5(loan, time, intrate, loanbal);
^
6 errors
Heres my array to make the program work
Any hints?
Code:
import java.io.*; import java.text.NumberFormat;// Number format import java.util.Locale;//sets location of currency class mortgagewk5 //name of program { public static void main(String[]arguments) throws IOException { NumberFormat nformat = NumberFormat.getCurrencyInstance(Locale.US); //currency format BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); LoanOptionsWk5[] Loans = new LoanOptionsWk5[3];//array setup for loans Loans[0] = new LoanOptionsWk5 (200000, 7, .0525);//first loan @ 200000 over 7 years at 5.25 intrest Loans[1] = new LoanOptionsWk5 (200000, 15, .0550);//second loan @ 20000 over 15 years at 5.5 interest Loans[2] = new LoanOptionsWk5 (200000, 30, .0575);//third loan @ 20000 over 30 years at 5.75 interest //print out of initial header information: output array data to screen, currency is formatted, and percentages are shown. System.out.println(); System.out.println("\tMortgage Calculator"); System.out.println(); System.out.println("Loan Amount = $" + nformat.format(Loans[0].getloan())); System.out.println("Years\t\t| " + Loans[0].gettime() + "\t\t" + Loans[1].gettime() + "\t\t" + Loans[2].gettime()); System.out.println("Interest Rate\t| " + Loans[0].getinterest()*100 + "%" + "\t" + Loans[1].getinterest()*100 + "%" + "\t\t" + Loans[2].getinterest()*100 + "%"); System.out.println("Monthly Payment\t| " + nformat.format(Loans[0].getmonthlypay()) + "\t" + nformat.format(Loans[1].getmonthlypay()) + "\t" + nformat.format(Loans[2].getmonthlypay())); System.out.println("_____________________________________________________________________"); //determine max months to determine number of monthly transactions to run int months = Loans[0].getmonths(); for (int i=0; i < Loans.length; i++) { if(Loans[i].getmonths() > months){ months = Loans[i].getmonths(); // new maximum } } //declare variables double intpay; double balpay; double loanbal = 0; //execute monthly transactions for(int i = 0; i < months+1; i++){ System.out.println("Month " + (i+1)); //execute each loan option for month for (int c=0; c < Loans.length; c++){ //declare variables double loan = Loans[c].getloan(); int time = Loans[c].gettime(); double intrate = Loans[c].getinterest(); //calculate mortgage information intpay = Loans[c].getbalance() * (Loans[c].getinterest()/12); //this is the interested paid each month balpay = Loans[c].getmonthlyPay() - intpay; //this is the amount paid towards principal each month loanbal = Loans[c].getbalance() - balpay; //this is the new loan balance after payment //print out monthly transactional information if (intpay > 0){ if (loanbal > 0){ System.out.println("\t" + time + " year loan - interest $" + nformat.format(intpay) + " Remaining balance $" + nformat.format(loanbal)); } else { System.out.println("\t" + time + " year loan - interest $" + nformat.format(intpay) + " Remaining balance $0.00"); } }else{ System.out.println("\t" + time + " Loan Completed"); } //set new loan balance for purposes of figuring monthly transactions Loans[c] = new LoanOptionsWk5(loan, time, intrate, loanbal); } System.out.println(); //conditional check to allow pause in output at intervals until key press if ((i % 10) == 0){ System.out.print("Press any key..."); try{ input.readLine(); } catch (Exception e){ e.printStackTrace(); } } } } }
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:19: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
LoanOptionsWk5[] Loans = new LoanOptionsWk5[3];//array setup for loans
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:19: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
LoanOptionsWk5[] Loans = new LoanOptionsWk5[3];//array setup for loans
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:21: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[0] = new LoanOptionsWk5 (200000, 7, .0525);//first loan @ 200000 over 7 years at 5.25 intrest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:22: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[1] = new LoanOptionsWk5 (200000, 15, .0550);//second loan @ 20000 over 15 years at 5.5 interest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:23: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[2] = new LoanOptionsWk5 (200000, 30, .0575);//third loan @ 20000 over 30 years at 5.75 interest
^
C:\Documents and Settings\Scott\Desktop\Mortgagewk5.java:77: cannot find symbol
symbol : class LoanOptionsWk5
location: class mortgagewk5
Loans[c] = new LoanOptionsWk5(loan, time, intrate, loanbal);
^
6 errors
Heres my array to make the program work
Code:
class loanoptionswk5{ //declare variables int aamount; int atime; int amonths; double aloanblance; double aintrate; //constructor for array and intiziation of variables loanoptionswk5(int amount,int time,double loanblance,double intrate) { aamount = amount; atime = time; aloanblance = loanblance; aintrate = intrate; } //Method of solving mortgages double getmonthlypay(){ double rate = aintrate / 12; //calculated monthly interest rate double payment = (aamount * rate) / (1 - (Math.pow(rate+1,-(atime*12)))); //monthly payment return payment; } int getmonths(){ amonths = atime * 12; return amonths; } double getinterest(){ return aintrate; } int getloan(){ return aamount; } int gettime(){ return atime; } double getblance(){ return aloanblance; } }
Comment