Results 1 to 6 of 6
- 03-19-2012, 07:48 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 16
- Rep Power
- 0
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:
Results: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);
run:
BUILD SUCCESSFUL (total time: 1 second):
- 03-19-2012, 08:45 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
Re: Java runs with no errors, but no output displays?
Does that code even compile?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-19-2012, 09:09 PM #3
Member
- Join Date
- Mar 2012
- Posts
- 16
- Rep Power
- 0
Re: Java runs with no errors, but no output displays?
I don't know how to tell if it compiles or not.
- 03-19-2012, 09:11 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-20-2012, 02:16 AM #5
Member
- Join Date
- Mar 2012
- Posts
- 16
- Rep Power
- 0
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.
- 03-20-2012, 10:21 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Similar Threads
-
Java Applet that displays two pictures with a button...
By yenujnassah in forum New To JavaReplies: 0Last Post: 11-10-2011, 09:54 AM -
Urgent: Swing application for stopwatch producing different output after a few runs
By princehektor in forum New To JavaReplies: 7Last Post: 09-20-2011, 05:21 PM -
setBounds not working (no errors; runs and compiles fine)
By cc11rocks in forum AWT / SwingReplies: 6Last Post: 02-08-2011, 02:29 AM -
First Java Program-Compile Errors (errors are posted)-simple GUI
By cc11rocks in forum AWT / SwingReplies: 4Last Post: 01-04-2011, 12:36 AM -
Applet Errors runs in jGrasp/ not in Eclipse and not in browser
By Wallsurfer in forum Java AppletsReplies: 10Last Post: 10-11-2009, 07:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks