Results 1 to 6 of 6
  1. #1
    felonee is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Java runs with no errors, but no output displays?

    Here's my assignment:

    Purpose: Modify the mortgage program to display 3 mortgage loans:
    7 year at 5.35%, 15 year at 5.50 %, and 30 year at 5.75%.
    Use an array for the different loans. Display the mortgage payment
    amount for each loan and then list the loan balance and interest paid
    for each payment over the term of the loan.
    Use loops to prevent lists from scrolling off the screen.

    Here's my code:

    Java Code:
    package mortgage.calculator.four;
    
    import java.io.*;  
    import java.lang.Object.*;  
    import java.text.DecimalFormat;  
    
    public class MortgageCalculatorFour
    {  
    
    public static void main(String[] args) throws Exception 
    {  
    
    // declare variables  
    int loanAmt = 200000; // principal loan amount  
    int[] loanTerm = { 84, 180, 360 }; // loan term for 30 years  
    int loanYears; // indicates the loan term in years  
    int[] paymentNumber = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; 
    
    //displays payment month in one year  
    double[] intRate = { 5.35, 5.50, 5.75 }; // interest rates  
    double newIntRate; // displays interest rate calculation  
    
    // decimal format  
    DecimalFormat money = new DecimalFormat("$0.00"); // displays decimal format  
    DecimalFormat money2 = new DecimalFormat("0.00%"); // displays interest rate in decimal format  
    DecimalFormat twoDigits = new DecimalFormat("$#,000.00"); // displays the change in balance  
    
    for(int termIndex = 0;termIndex < loanTerm.length;termIndex++) {   
    for(int rateIndex = 0;rateIndex < intRate.length;rateIndex++) {    
    }
    
    // end rate for  
    }
    
    // end term for  
    }  
    } 
    
    //declare variables  
    for (monthlyPay = loanAmt * intRate / (1 - Math.pow((1 + intRate), - loanTerm));  
    monthlyPrincipal = loanAmt - (loanAmt * intRate /(1-Math.pow((1 + intRate),- loanTerm))- loanAmt * intRate);  
    
    principalPayment = loanAmt - monthlyPrincipal);//calculates interest paid on the loan  
    for (interestPayment = monthlyPay - principalPayment;  
    
    // screen display  
    System.out.println("\tThis program will calculate 3 Different Mortgage Payments");  
    System.out.println();
    
    //space  
    System.out.println("\t\t\tFor a Mortgage of $" + loanAmt);  
    System.out.println("\t\tWith Loan Terms and Interest Rates of:");  
    System.out.println();//space  
    System.out.println("\t\t\t\t7 years @ 5.35%");  
    System.out.println("\t\t\t\t15 years @ 5.50%");  
    System.out.println("\t\t\t\t30 years @ 5.75%");  
    System.out.println();
    
    //space  
    System.out.println();
    
    //space  
    System.out.println("The results are as follows:");  
    
    {  
    
    int i;  
    for (i = 0; i <= 2; i++)  
    intRate[i] = (intRate[i] /12 * .01);  
    monthlyPay = loanAmt * intRate[i] / (1 - Math.pow(1 + intRate[i], - loanTerm[i]));  
    
    // output results to user  
    
    System.out.println();  
    System.out.println("\tThe mortgage payment for a $" + loanAmt + " loan for " + loanTerm[i] / 12 + " years at");  
    
    System.out.println("\ta " + (money2.format(intRate [i] /12 * .01) + " interest rate = " + (money.format(monthlyPay))));  
    
    //declare method variable  
    double loanBalance = ((loanAmt - loanAmt)  - monthlyPay);  
    
    //screen display  
    System.out.println("_____________________________________________________________________________");  
    
    System.out.println();
    
    //space  
    System.out.println("Year#\t\tInterest\tPrincipal\tBalance");  
    System.out.println("_____________________________________________________________________________");  
    
    int count = 0;//counter to determine how many rows have been displayed  
    while (loanBalance>0)//loop  
    
    count++; //increments while looping  
    
    System.out.println(paymentNumber + "\t\t" + twoDigits.format(interestPayment) + "\t\t" + twoDigits.format(principalPayment) + "\t\t" + twoDigits.format(loanBalance));  
    
    // screen display  
    System.out.print("\n Amortization Schedule Press Enter... ");  
    System.out.println();//space  
    
    try {  
    
    InputStreamReader reader = new InputStreamReader(System.in);  
    BufferedReader buffer = new BufferedReader(reader);  
    buffer.readLine();  
    }  
    catch (Exception e) {  
    System.exit (0);
    Results:
    run:
    BUILD SUCCESSFUL (total time: 1 second):

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java runs with no errors, but no output displays?

    Does that code even compile?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    felonee is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Re: Java runs with no errors, but no output displays?

    I don't know how to tell if it compiles or not.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java runs with no errors, but no output displays?

    Do you know how to compile .java files? Read the manual that came with your IDE.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    felonee is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Re: Java runs with no errors, but no output displays?

    I have netbeans. I'm attending Univ of Phoenix, and since this is a Bachelor's level class, they only last 5 weeks. I'm having trouble learning a program in that amount of time. I appreciate the feedback though.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default Re: Java runs with no errors, but no output displays?

    You're using Netbeans and it doesn't auto-indent?
    Without some formatting it's rather hard to follow.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Java Applet that displays two pictures with a button...
    By yenujnassah in forum New To Java
    Replies: 0
    Last Post: 11-10-2011, 09:54 AM
  2. Replies: 7
    Last Post: 09-20-2011, 05:21 PM
  3. Replies: 6
    Last Post: 02-08-2011, 02:29 AM
  4. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  5. Replies: 10
    Last Post: 10-11-2009, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •