import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class 3 Mortgage loans {
// declare class variable array
int[] mortgage calculator
//construct the array
mortgage calculator = new int[17];
Expand|Select|Wrap|Line Numbers
-
- Expand|Select|Wrap|Line Numbers
- 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