944,110 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1750
  • Java RSS
Feb 20th, 2006
0

Array issue

Expand Post »
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
Java Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dmgs11 is offline Offline
6 posts
since Feb 2006
Feb 21st, 2006
0

Re: Array issue

This isn't an array:
Java Syntax (Toggle Plain Text)
  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];
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Applet / Array help
Next Thread in Java Forum Timeline: Error while compiling but not in the code itself????





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC