though the maortgagae cals works correctly the answers are not i columns

import java.io.*;  

     import static java.lang.Math.*;  

     import java.util.Scanner;  

     import java.text.DecimalFormat;  

     import java.text.NumberFormat;  

 /**  

  * @(#)AmortWeek3.java  

  *  

  * AmortWeek3 application  

  *  

  * @author    

  *          Week 3-Service Request SR-mf-003  

  *                 Change Request 1  

  *                  Display breakdown of monthly payments  
  *  

  * @version 1.00 2011/3/4  

 */  

    

 public class AmortWeek3 {  
    

      public static void main(String[] args) {  

    

        // Mortgage Calculation Formula Payment = (principal * interest) / (1 -- (1 + interest)^-number of payments)  

    

         //Declaring the variables that will be used in the program  

        double monthlyPmt;                          //Monthly Payment  

         double principalAmt = 200000;               //Amount of principal  

         double intRate = .0575;                     //Annual interest rate  

         double monthlyIntRate = intRate / 12;       //Monthly interest rate  

         double loanTerm = 360;                      //Total number of months  

         double counter = 0;                             //Counter  

    

     //Calculate monthly payment  

     monthlyPmt = (principalAmt*(monthlyIntRate*(Math.pow((1+monthlyIntRate), loanTerm)  

                )))/((Math.pow((1+monthlyIntRate),loanTerm))-1);  

    

     DecimalFormat Currency = new DecimalFormat("$#,##0.00");  

    

       //Display monthly payment  

       System.out.println("Amoritized monthly payment for McBride");  

       String payment = Currency.format(monthlyPmt);  

       System.out.print(payment);  

       System.out.println();  

       System.out.println();  

    

           //Formula needs to broken down from (principal * interest rate) to calculate the interest for length of loan  

    

         //Columnar headers  

         final int PAYMENT_WIDTH = 10;  

         final int AMOUNT_WIDTH = 15;  

         final int PRINCIPAL_WIDTH = 15;  

         final int INTEREST_WIDTH = 15;  

         final int BALANCE_WIDTH = 15;  

    

     String pattern = "%" + PAYMENT_WIDTH + "s%" + AMOUNT_WIDTH + "s%" + PRINCIPAL_WIDTH + "s%" + INTEREST_WIDTH + "s%" + BALANCE_WIDTH + "s";  

    

     System.out.printf(pattern, "PAYMENT", "AMOUNT", "PRINCIPAL", "INTEREST", "BALANCE");  

    

     System.out.println();  

    

     NumberFormat nf = NumberFormat.getCurrencyInstance();  

    

     for (int month = 1; month <= loanTerm; month++) {  

    

     double amountInterest = principalAmt * monthlyIntRate;  

    

     double amountPrincipal = monthlyPmt - amountInterest;  

    

     principalAmt = principalAmt - amountPrincipal;  

    

     System.out.printf(pattern, month, nf.format(monthlyPmt), nf.format(amountPrincipal), nf.format(amountInterest), nf.format(principalAmt));  

    

            if (month == 25) {  

             month =0;  

            try {  

            Scanner keyIn = new Scanner(System.in);  

         System.out.print("(Press ENTER to see more months");  

            System.in.read();                                     // Look for keyboard input  

            } catch (IOException e) {                             // Catch the input  

            return;                                               // Continue the program  

            }  

            month= month+1;                                      // Increment line counter  

            } else {  

    

     }  

      }  

     }  

 }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.