Array issue

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2006
Posts: 6
Reputation: dmgs11 is an unknown quantity at this point 
Solved Threads: 0
dmgs11 dmgs11 is offline Offline
Newbie Poster

Array issue

 
0
  #1
Feb 20th, 2006
Error
.java:132: incompatible types
found : int
required: int[]
int[] months= numOfYears[i]*12; //The variable used for user input for exact month information
^
1 error

Tool completed with exit code 1
  1. public void actionPerformed(ActionEvent Mortgage) { // Starts Mortgage Calculator
  2. DecimalFormat decimalPlaces=new DecimalFormat("0.00");
  3. appMonthlyPayment.setText("");
  4.  
  5. // The next 3 lines get the values from the text boxes. - The only user entry will be principal for this version
  6. // term = Integer.parseInt(appTerm.getText());
  7. // interest = Double.parseDouble(appTerm.getText());
  8. principal = Double.parseDouble(appPrincipal.getText());
  9.  
  10.  
  11. //Calculate Monthly Interest
  12. double monthlyInterest = annualInterests[i]/(12*100);
  13. int totalNumOfMonths = numOfYears[i]*12;
  14.  
  15. int[] months= numOfYears[i]*12; //The variable used for user input for exact month information
  16. monthlyInterest = interest/(12 * 100); //calculate the monthly interst using simple interest.
  17. double denominator= Math.pow(1 + monthlyInterest, -(numOfYears[i]*12));
  18. denominator= 1 - denominator;
  19. double monthlyPayment= principal * (monthlyInterest/ denominator);
  20. }
  21. public double getMortgageAmount(double principal, double monthlyInterest, int numOfMonths){
  22. // Monthly payment formula: M = P x (J/(1-(1+J)^-N));
  23. // M = P * ( J / (1 - (1 + J) ** -N));
  24. // source: http://www.hughchou.org/calc/formula.html
  25. double monthlyPayment= (double)(principal*(monthlyInterest / (1-(Math.pow((1+monthlyInterest),(numOfMonths*-1))))));
  26. return monthlyPayment;
  27.  
  28. double getMonthlyPrincipal, remainingPrincipal; //calculate the monthly interst using simple interest.
  29.  
  30. return monthlyPayment - (remainingPrincipal * monthlyInterest);
  31.  
  32. appMonthlyPayment.setText("Payment = " + monthlyPayment); // Finally, set the text field to show the result
  33. } // Ends Mortgage Calculator
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Array issue

 
0
  #2
Feb 21st, 2006
This isn't an array:
  1. int[] months= numOfYears[i]*12; //The variable used for user input for exact month information

Shouldn't it be:

int[] months= numOfYears[i*12];
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC