468,505 Members | 1,600 Online

# 3 mortgage loan calculator 4
please help resolve some error messages code is compling with errors
see below the code. I am new at this please help!

/**
* @(#)3 Mortgage loans.java
*
* 3 Mortgage loans application
*
* Phyllis J Jones
* Purpose to write a program in Java without a graphical user interface and have
it calculate the payment amount for 3 mortgage loans.
*/
import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class MortgageLoans {

// declare class variable array
double mortgage calculator1[];
double mortgage calculator2[];
double mortgage calculator3[];
//construct the array
mortgage calculator1 = new double;
mortgage calculator2 = new double;
mortgage calculator3 = new double;

double loan = 200000
double term1 =360//*360 month for 30 year mortgage
double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
double monthlyRate1 = (interestRate1/12)
double term2 = 84//*7year mortgage loan
double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
double term3 = 180 // 15 year mortgage
double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage

//Discount factr calculator for the three loans
double discountFactor1 = (Math.pow ((1 + monthlyRate1),
term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));

double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/
(monthlyRate2* Math.pow((1 + monthlyRate2),term2));

double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
(monthlyRate3 * Math.pow((1 + monthlyRate3), term3));

double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage

//loop While not done
while(loan > 0)
{

java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00");
System.out.println("Your monthly payment is \$" + dfm.format(payment)+ "cemts");
// loop while done
if(loan>0)
{
double payment1 = loan/discountFactor1;//*Rate Calculation
double payment2 = loan/discountFactor2;//*Rate Calculation
double payment3 = loan/duiscountFactor3;//*Rate Calculation
}
else
payment1 = payment/discountFactor1;//Rate Calculation
payment2 = payment/discountFactor2;//Rate Calcuklation
payment3 = payment/discountfactor3;//Rate Calculation
}
//Output

}

}
Dec 8 '06 #1
1 9397 horace1
1,510 Expert 1GB
fixed a few errors - what is now missing is the variable payment
Expand|Select|Wrap|Line Numbers
1. /**
2. * @(#)3 Mortgage loans.java
3. *
4. * 3 Mortgage loans application
5. *
6. * Phyllis J Jones
7. * Purpose to write a program in Java without a graphical user interface and have
8. it calculate the payment amount for 3 mortgage loans.
9. */
10. import java.math.*;//*loan calculator
11. import java.text.*;//*formats numbers
12. public class MortgageLoans {
13.
14. public static void main(String args[])  // ** added
15. {
16.
17.
18. // declare class variable array
19. double mortgageCalculator1[] = new double;  // ** new added ;
20. double mortgageCalculator2[] = new double;
21. double mortgageCalculator3[] = new double;
22. //construct the array
23. //mortgageCalculator1 = new double;
24. //mortgageCalculator2 = new double;
25. //mortgageCalculator3 = new double;
26.
27.
28. double loan = 200000;  // ** add ;
29. double term1 =360;//*360 month for 30 year mortgage
30. double interestRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
31. double monthlyRate1 = (interestRate1/12); // ** ; added
32. double term2 = 84;//*7year mortgage loan
33. double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
34. double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
35. double term3 = 180; // 15 year mortgage
36. double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
37. double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
38.
39. //Discount factr calculator for the three loans
40. double discountFactor1 = (Math.pow ((1 + monthlyRate1),term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1))); // ** added )
41.
42. double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/(monthlyRate2* Math.pow((1 + monthlyRate2),term2))); // ** added )
43.
44. double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/(monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
45.
46. double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
47. double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
48. double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage
49.
50.
51. //loop While not done
52. while(loan > 0)
53. {
54.
55. java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00");
56. System.out.println("Your monthly payment is \$" + dfm.format(payment)+ "cemts");
57. // loop while done
58. if(loan>0)
59. {
60. payment1 = loan/discountFactor1;//*Rate Calculation
61. payment2 = loan/discountFactor2;//*Rate Calculation
62. payment3 = loan/discountFactor3;//*Rate Calculation
63. }
64. else
65. payment1 = payment/discountFactor1;//Rate Calculation
66. payment2 = payment/discountFactor2;//Rate Calcuklation
67. payment3 = payment/discountFactor3;//Rate Calculation
68. }
69. //Output
70.
71. }
72.
73. }
74.
Dec 8 '06 #2

### Post your reply

Sign in to post your reply or Sign up for a free account.

### Similar topics

 3 posts views Thread by promiscuoustx | last post: by 2 posts views Thread by phjones | last post: by 1 post views Thread by phjones | last post: by 1 post views Thread by dylbin | last post: by 3 posts views Thread by zaidalin79 | last post: by 8 posts views Thread by LadiPrather | last post: by reply views Thread by ravipankaj | last post: by reply views Thread by NPC403 | last post: by reply views Thread by slotstar | last post: by 7 posts views Thread by isladogs | last post: by 1 post views Thread by rhonda6373 | last post: by 4 posts views Thread by Eddie2020 | last post: by 3 posts views Thread by gieforce | last post: by reply views Thread by theflame83 | last post: by reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.