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:
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):
Re: Java runs with no errors, but no output displays?
Does that code even compile?
kind regards,
Jos
Re: Java runs with no errors, but no output displays?
I don't know how to tell if it compiles or not.
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
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.
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.