| | |
Cannot find sybol Constructor and Methods
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2007
Posts: 4
Reputation:
Solved Threads: 0
So I'm in the final days of being able to turn this in, yes it is a homework assignment, but I've almost got it completely done. In fact I'm only having issues with like the last 8 lines. (at least that's all that is causing an error right now.)
Here is what is happening. I designed a mortgage calculator last week that displayed the Loan Amount, the terms, the interest and then calculated the monthly payment. This week I need to make it figure out the Principle Balance and the Interest Paid each month. This will go off the screen so I tried to use loops. Not sure if I know what I'm doing. Just when I think I got it, I dont.
Any help or points in the right direction would be greatly appreciated! Thanks!
Here is what is happening. I designed a mortgage calculator last week that displayed the Loan Amount, the terms, the interest and then calculated the monthly payment. This week I need to make it figure out the Principle Balance and the Interest Paid each month. This will go off the screen so I tried to use loops. Not sure if I know what I'm doing. Just when I think I got it, I dont.
Java Syntax (Toggle Plain Text)
* Service Request: SR-mf-03 Mortgage Payment Calculator * Purpose: Complete Change Request #1 in Service Request SR-mf-003, Write the program in Java (without a graphical user interface) using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term. Display the mortgage payment amount and then list the loan balance and interest paid for each payment over the term of the loan. If the list would scroll off the screen, use loops to display a partial list, hesitate, and then display more of the list. Insert comments in the program to document the program. * Mortgage Payment Formula From http://www.rihomesearch.com/15.php. P= Principal I= Interest Rate L= Length J= Monthly Interest N= Number of Month Loan is Amortized * Monthly payment (M) formula: M = P * ( J / (1 - (1 + J)** -N)) */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.*; public class MortgagePaymentCalc4 { /* Calculate mortgage payment. The calculation is based on the fixed input which * are set by variables PrincipleBalance, MonthlyInterest, and Months. */ public static void main(String[] args) { // Declare Variables int Months; double MonthlyPayment, PrincipleBalance, MonthlyInterest; // Initialize Variables PrincipleBalance = 200000; // Mortgage Amount MonthlyInterest = 5.75 / (12*100); // Monthly Interest Months = 30 * 12; // Mortgage Length MonthlyPayment = 0; // Monthly Payment // Calculate Monthly Payment MonthlyPayment = PrincipleBalance * (MonthlyInterest / (1 - Math.pow(1/(1+MonthlyInterest), Months))); // Round Cent Decimal DecimalFormat RoundtoCents = new DecimalFormat("0.00"); //Output Calculation System.out.println(); System.out.println("\t\t\tMcBride Financial Services"); System.out.println("\t\t Monthly Mortgage Payment Calculator"); System.out.println(); System.out.println(); System.out.println("\t\t\tPrincipal Mortgage: $"+Math.round(PrincipleBalance)+"."); System.out.println("\t\t\tInterest Rate: "+MonthlyInterest*12*100+"%."); System.out.println("\t\t\tTerm: "+Months/12+" years"); System.out.println(); System.out.println(); System.out.println("\t\t\tMonthly Payment: $"+RoundtoCents.format(MonthlyPayment)+"."); System.out.println(); } public void listBal() { System.out.println(); System.out.println("Month " + "\t" + "Amount " + "\t\t" + "Interest " + "\t" + "Balance "); // Declare Variables int periods = 1, Months; double Balance, Interest, MonthlyPayment, PrincipleBalance, MonthlyInterest; while(periods <=Months) { int i = 0; while(i <10) { Balance = PrincipleBalance*(1+MonthlyInterest) - MonthlyPayment; //Calculation of Balance Interest = PrincipleBalance*MonthlyInterest; //Calculation of Interest //Now print using the round to two decimal places System.out.println(""+periods +"\t\t"+(Math.round(PrincipleBalance*100.00)/100.00)+"\t\t"+(Math.round(Interest*100.00)/100.00)+"\t\t"+(Math.round(Balance*100.00)/100.00)); PrincipleBalance = Balance; //Set the Principal for next round to the Balance of previous month periods++; i++; } System.out.println("Press Enter to continue.."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1); String str = ""; try { str = br.readLine(); } catch (IOException ioe) { System.out.println(ioe); } } } { MortgagePaymentCalc4 mc2 = new MortgagePaymentCalc4(25, (double)200000, (double)0.0575); //Calculate Monthly payment mc2.CalcMonthlyPayment(); //Show the output mc2.DisplayMonthlyPayment(); mc2.listPrincipleBalance(); } }
Any help or points in the right direction would be greatly appreciated! Thanks!
•
•
Join Date: Dec 2007
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Because you are trying to call methods on the class that you have not written. Those methods don't exist in the code that you posted.
What am I missing??
Java Syntax (Toggle Plain Text)
* Service Request: SR-mf-03 Mortgage Payment Calculator * Purpose: Complete Change Request #1 in Service Request SR-mf-003, Write the program in Java (without a graphical user interface) using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term. Display the mortgage payment amount and then list the loan balance and interest paid for each payment over the term of the loan. If the list would scroll off the screen, use loops to display a partial list, hesitate, and then display more of the list. Insert comments in the program to document the program. * Filename: MortgagePaymentCalc.java * Developed: December 20, 2007 * Version: 2 * Mortgage Payment Formula From http://www.rihomesearch.com/15.php. P= Principal I= Interest Rate L= Length J= Monthly Interest N= Number of Month Loan is Amortized * Monthly payment (M) formula: M = P * ( J / (1 - (1 + J)** -N)) */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.*; public class MortgagePaymentCalc4 { /* Calculate mortgage payment. The calculation is based on the fixed input which * are set by variables PrincipleBalance, MonthlyInterest, and Months. */ public static void main(String[] args) { // Declare Variables int Months; double MonthlyPayment, PrincipleBalance, MonthlyInterest; // Initialize Variables PrincipleBalance = 200000; // Mortgage Amount MonthlyInterest = 5.75 / (12*100); // Monthly Interest Months = 30 * 12; // Mortgage Length MonthlyPayment = 0; // Monthly Payment // Calculate Monthly Payment MonthlyPayment = PrincipleBalance * (MonthlyInterest / (1 - Math.pow(1/(1+MonthlyInterest), Months))); // Round Cent Decimal DecimalFormat RoundtoCents = new DecimalFormat("0.00"); //Output Calculation System.out.println(); System.out.println("\t\t\tMcBride Financial Services"); System.out.println("\t\t Monthly Mortgage Payment Calculator"); System.out.println(); System.out.println(); System.out.println("\t\t\tPrincipal Mortgage: $"+Math.round(PrincipleBalance)+"."); System.out.println("\t\t\tInterest Rate: "+MonthlyInterest*12*100+"%."); System.out.println("\t\t\tTerm: "+Months/12+" years"); System.out.println(); System.out.println(); System.out.println("\t\t\tMonthly Payment: $"+RoundtoCents.format(MonthlyPayment)+"."); System.out.println(); } private int Period; //Instance variables private double LoanAmount; private double MonthlyInterestRate; private double MonthlyPayment; int Months; double PrincipleBalance, MonthlyInterest; //constructor for user defined values public MortgagePaymentCalc4(int _Period, double LA, double IR){ Period = _Period; LoanAmount = LA; MonthlyInterestRate = IR/12; // Initialize Variables PrincipleBalance = 200000; // Mortgage Amount MonthlyInterest = 5.75 / (12*100); // Monthly Interest Months = 30 * 12; // Mortgage Length MonthlyPayment = 0; // Monthly Payment } public int GetPeriod(){ return Period; } public void SetPeriod(int Period){ this.Period = Period; } public double GetLoanAmount(){ return LoanAmount; } public void SetLoanAmount(double LoanAmount){ this.LoanAmount = LoanAmount; } public double GetMonthlyInterestRate(){ return MonthlyInterestRate; } public void SetMonthlyInterestRate(double InterestRate){ this.MonthlyInterestRate = InterestRate/12; } public void CalcMonthlyPayment(){ MonthlyPayment = LoanAmount*Math.pow(1+MonthlyInterestRate, Period)*MonthlyInterestRate/(Math.pow(1+MonthlyInterestRate, Period) -1); } public String ToString (double value){ return Double.toString(value); } public void DisplayMonthlyPayment(){ System.out.println("Monthly Payment = $" +ToString(MonthlyPayment)); } public void listPrincipleBal() { System.out.println(); System.out.println("Month " + "\t" + "Amount " + "\t\t" + "Interest " + "\t" + "Balance "); // Declare Variables int periods = 1, Months; double Balance, Interest, MonthlyPayment, PrincipleBalance, MonthlyInterest; // Initialize Variables PrincipleBalance = 200000; // Mortgage Amount MonthlyInterest = 5.75 / (12*100); // Monthly Interest Months = 30 * 12; // Mortgage Length MonthlyPayment = 0; // Monthly Payment while(periods <=Months) { int i = 0; while(i <10) { Balance = PrincipleBalance*(1+MonthlyInterest) - MonthlyPayment; //Calculation of Balance Interest = PrincipleBalance*MonthlyInterest; //Calculation of Interest //Now print using the round to two decimal places System.out.println(""+periods +"\t\t"+(Math.round(PrincipleBalance*100.00)/100.00)+"\t\t"+(Math.round(Interest*100.00)/100.00)+"\t\t"+(Math.round(Balance*100.00)/100.00)); PrincipleBalance = Balance; //Set the Principal for next round to the Balance of previous month periods++; i++; } System.out.println("Press Enter to continue.."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1); String str = ""; try { str = br.readLine(); } catch (IOException ioe) { System.out.println(ioe); } } } { MortgagePaymentCalc4 mc3 = new MortgagePaymentCalc4(25, (double)200000, (double)0.0575); //Calculate Monthly payment mc3.CalcMonthlyPayment(); //Show the output mc3.DisplayMonthlyPayment(); mc3.listPrincipleBal(); } }
![]() |
Other Threads in the Java Forum
- Previous Thread: java help
- Next Thread: how to access an application from the Domain Server
Views: 1881 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation binary bluetooth c# capture chat chatprogramusingobjects class classes client code color component count database design draw eclipse eclipsedevelopment encryption error event exception file fractal game givemetehcodez graphics gridlayout gui helpwithhomework high html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jmf jni jpanel julia keyword linux list loop macintosh map method methods mobile netbeans newbie number object oracle os print problem producer program programming project projectideas read recursion replaysolutions scanner screen server set size sms socket sort sql string swing test threads time transfer transforms tree ui unicode windows






