0

I need my rows to allign like this and my code is below, can someone tell me what I should do.

Loan 1 15,000 12% 60 $333.67 $5,020.20 $20,020.20
Loan 2 15,000 10% 48 $xxx.xx $x,xxx.xx $xx,xxx.xx
Loan 3 15,000 08% 36 $xxx.xx $x,xxx.xx $xx,xxx.xx

import java.math.*; 
import java.text.*; 

 

class Mortgage2Rev {
     public static void main(String arguments[]) {

	
//Program Variables
    double term1 = 84;
    double term2 = 180;
    double term3 = 360;
    double interestRate1 = 0.0535; 
    double interestRate2 = 0.055;
    double interestRate3 = 0.0575;
    double loan = 200000;
    
    double term, interestRate;
    
    DecimalFormat df = new DecimalFormat("$###,###.00");
    
//Calculates the Payment per month to be paid under mortgage scheme One
    interestRate=interestRate1;
    term=term1;
    double monthlyRate = (interestRate/12);
    double discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
    double payment1 = loan / discountFactor; 
    
//Output for mortage scheme One
    System.out.println("Amount:"+df.format(loan)+"\n");       
    System.out.println("Intrest:"+interestRate*100+"%");   
    System.out.println("Term:"+term/12+" years.");    
    System.out.println("Payment: " + df.format(payment1)+"\n");
    
 //Calculates the Payment per month to be paid under mortgage scheme Two
    interestRate=interestRate2;
    term=term2;
    monthlyRate = (interestRate/12);
    discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
    double payment2 = loan / discountFactor;
     
//Output for mortgage scheme Two
    System.out.println("Intrest:"+interestRate*100+"%");
    System.out.println("Term:"+term/12+" years.");
    System.out.println("Payment: " + df.format(payment2) +"\n");
     
//Calculates the Payment per month to be paid under mortgage Three
    interestRate=interestRate3;
    term=term3;
    monthlyRate = (interestRate/12);
    discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
    double payment3 = loan / discountFactor; 
    
//Output for morgage scheme Three
    System.out.println("Intrest:"+interestRate*100+"%");
    System.out.println("Term:"+term/12+" years.");
    System.out.println("Payment: " + df.format(payment3)+"\n");
    System.out.print("\t"); 

}
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by peter_budo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.