Page 1 of 1

array

Posted: Tue May 04, 2004 8:44 pm
by mesalaza
hi, i was trying to write a program with multiple arrays but i cannot figure it out. i was hoping someone could help me out. i would like to calculate these into it 7 year at 5.35%, 15 year at 5.5 %,
//and 30 year at 5.75%. here is my code


public class Calculator {


public static void main(String[] args)
{
System.out.println("Ramon's Mortgage Calculator!");
System.out.println (" ");

double loan, years, totalinterestpaid, monthlypayment;

loan = 200000; //loan amount
years = 30; //years of loan
totalinterestpaid = 220174;

monthlypayment = ((totalinterestpaid + loan)/ 360);
System.out.print("Your total monthly mortgage payment is ");
System.out.println(monthlypayment);
System.out.println (" ");

double loanbalance, interest, monthlyinterest;

int months;

months = 0
;while (months < 16){
interest = loan * .00479166;
loanbalance = loan;
loan = loan - monthlypayment + interest;
monthlyinterest = loan * .00479166;
months = months + 1;
System.out.print ("Loan Balance for month ");
System.out.print (months);
System.out.print (" is $");
System.out.println (loanbalance);
System.out.print ("Intrest paid for month ");
System.out.print (months);
System.out.print (" is $");
System.out.println (monthlyinterest);
System.out.println (" ");
}
;while (months < 16){
interest = loan * .00479166;
loanbalance = loan;
loan = loan - monthlypayment + interest;
monthlyinterest = loan * .00479166;
months = months + 1;
System.out.print ("Loan Balance for month ");
System.out.print (months);
System.out.print (" is $");
System.out.println (loanbalance);
System.out.print ("Intrest paid for month ");
System.out.print (months);
System.out.print (" is $");
System.out.println (monthlyinterest);
System.out.println (" ");
}


}
}

Posted: Tue May 04, 2004 9:34 pm
by MudGuard
There is only one array in the whole thing - and that one is ignored (the args parameter of main method).

So where is your problem with arrays?

Btw, the second while loop will never be entered - it checks whether months < 16, but after the first while loop, months == 16.

Posted: Tue May 04, 2004 9:51 pm
by MudGuard
Oh, and btw, please put Java questions into the Java forum, not the General Textpad forum.

(and even the Java forum here at Textpad is in my opinion for questions relating to Java AND Textpad, i.e. for problems with java compiler run as a tool from Textpad)