Cannot find sybol Constructor and Methods

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 4
Reputation: Jessica892 is an unknown quantity at this point 
Solved Threads: 0
Jessica892 Jessica892 is offline Offline
Newbie Poster

Cannot find sybol Constructor and Methods

 
0
  #1
Dec 20th, 2007
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.

  1. * Service Request: SR-mf-03 Mortgage Payment Calculator
  2. * Purpose: Complete Change Request #1 in Service Request SR-mf-003,
  3. Write the program in Java (without a graphical user interface)
  4. using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term.
  5. Display the mortgage payment amount and then list the loan balance and interest paid
  6. for each payment over the term of the loan. If the list would scroll off the screen,
  7. use loops to display a partial list, hesitate, and then display more of the list.
  8. Insert comments in the program to document the program.
  9. * Mortgage Payment Formula From http://www.rihomesearch.com/15.php.
  10. P= Principal
  11. I= Interest Rate
  12. L= Length
  13. J= Monthly Interest
  14. N= Number of Month Loan is Amortized
  15. * Monthly payment (M) formula:
  16. M = P * ( J / (1 - (1 + J)** -N))
  17. */
  18.  
  19. import java.io.BufferedReader;
  20. import java.io.IOException;
  21. import java.io.InputStreamReader;
  22. import java.text.*;
  23. public class MortgagePaymentCalc4
  24. {
  25. /* Calculate mortgage payment. The calculation is based on the fixed input which
  26. * are set by variables PrincipleBalance, MonthlyInterest, and Months.
  27. */
  28. public static void main(String[] args)
  29. {
  30.  
  31. // Declare Variables
  32. int Months;
  33. double MonthlyPayment, PrincipleBalance, MonthlyInterest;
  34.  
  35. // Initialize Variables
  36. PrincipleBalance = 200000; // Mortgage Amount
  37. MonthlyInterest = 5.75 / (12*100); // Monthly Interest
  38. Months = 30 * 12; // Mortgage Length
  39. MonthlyPayment = 0; // Monthly Payment
  40.  
  41. // Calculate Monthly Payment
  42. MonthlyPayment = PrincipleBalance * (MonthlyInterest / (1 - Math.pow(1/(1+MonthlyInterest), Months)));
  43.  
  44. // Round Cent Decimal
  45. DecimalFormat RoundtoCents = new DecimalFormat("0.00");
  46.  
  47. //Output Calculation
  48. System.out.println();
  49. System.out.println("\t\t\tMcBride Financial Services");
  50. System.out.println("\t\t Monthly Mortgage Payment Calculator");
  51. System.out.println();
  52. System.out.println();
  53. System.out.println("\t\t\tPrincipal Mortgage: $"+Math.round(PrincipleBalance)+".");
  54. System.out.println("\t\t\tInterest Rate: "+MonthlyInterest*12*100+"%.");
  55. System.out.println("\t\t\tTerm: "+Months/12+" years");
  56. System.out.println();
  57. System.out.println();
  58. System.out.println("\t\t\tMonthly Payment: $"+RoundtoCents.format(MonthlyPayment)+".");
  59. System.out.println();
  60. }
  61.  
  62.  
  63. public void listBal()
  64. {
  65.  
  66. System.out.println();
  67. System.out.println("Month " + "\t" + "Amount " + "\t\t" + "Interest " + "\t" + "Balance ");
  68.  
  69. // Declare Variables
  70. int periods = 1, Months;
  71. double Balance, Interest, MonthlyPayment, PrincipleBalance, MonthlyInterest;
  72. while(periods <=Months)
  73. {
  74. int i = 0;
  75. while(i <10)
  76. {
  77. Balance = PrincipleBalance*(1+MonthlyInterest) - MonthlyPayment; //Calculation of Balance
  78. Interest = PrincipleBalance*MonthlyInterest; //Calculation of Interest
  79. //Now print using the round to two decimal places
  80. 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));
  81. PrincipleBalance = Balance; //Set the Principal for next round to the Balance of previous month
  82. periods++;
  83. i++;
  84. }
  85. System.out.println("Press Enter to continue..");
  86. BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
  87. String str = "";
  88. try
  89. {
  90. str = br.readLine();
  91. }
  92. catch (IOException ioe) { System.out.println(ioe); }
  93. }
  94. }
  95.  
  96. {
  97.  
  98. MortgagePaymentCalc4 mc2 = new MortgagePaymentCalc4(25, (double)200000, (double)0.0575);
  99.  
  100. //Calculate Monthly payment
  101. mc2.CalcMonthlyPayment();
  102. //Show the output
  103. mc2.DisplayMonthlyPayment();
  104. mc2.listPrincipleBalance();
  105. }
  106. }

Any help or points in the right direction would be greatly appreciated! Thanks!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: Jessica892 is an unknown quantity at this point 
Solved Threads: 0
Jessica892 Jessica892 is offline Offline
Newbie Poster

Re: Cannot find sybol Constructor and Methods

 
0
  #2
Dec 20th, 2007
So I just solved the constructor issue, left it blank as a blank () instead of the 25, double, double stuff.

Now if only posting this would make me figure out the last mc2. issue. It's pointing to the period on all three of those. Any idea?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,511
Reputation: Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future Ezzaral has a brilliant future 
Solved Threads: 522
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Cannot find sybol Constructor and Methods

 
0
  #3
Dec 20th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: Jessica892 is an unknown quantity at this point 
Solved Threads: 0
Jessica892 Jessica892 is offline Offline
Newbie Poster

Re: Cannot find sybol Constructor and Methods

 
0
  #4
Dec 21st, 2007
Originally Posted by Ezzaral View Post
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.
O.k. here is my new stuff. It compiles successfully but it only displays my original calculator, not the interest and principle, looping.

What am I missing??

  1. * Service Request: SR-mf-03 Mortgage Payment Calculator
  2. * Purpose: Complete Change Request #1 in Service Request SR-mf-003,
  3. Write the program in Java (without a graphical user interface)
  4. using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term.
  5. Display the mortgage payment amount and then list the loan balance and interest paid
  6. for each payment over the term of the loan. If the list would scroll off the screen,
  7. use loops to display a partial list, hesitate, and then display more of the list.
  8. Insert comments in the program to document the program.
  9. * Filename: MortgagePaymentCalc.java
  10. * Developed: December 20, 2007
  11. * Version: 2
  12. * Mortgage Payment Formula From http://www.rihomesearch.com/15.php.
  13. P= Principal
  14. I= Interest Rate
  15. L= Length
  16. J= Monthly Interest
  17. N= Number of Month Loan is Amortized
  18. * Monthly payment (M) formula:
  19. M = P * ( J / (1 - (1 + J)** -N))
  20. */
  21.  
  22. import java.io.BufferedReader;
  23. import java.io.IOException;
  24. import java.io.InputStreamReader;
  25. import java.text.*;
  26. public class MortgagePaymentCalc4
  27. {
  28. /* Calculate mortgage payment. The calculation is based on the fixed input which
  29. * are set by variables PrincipleBalance, MonthlyInterest, and Months.
  30. */
  31. public static void main(String[] args)
  32. {
  33.  
  34. // Declare Variables
  35. int Months;
  36. double MonthlyPayment, PrincipleBalance, MonthlyInterest;
  37.  
  38. // Initialize Variables
  39. PrincipleBalance = 200000; // Mortgage Amount
  40. MonthlyInterest = 5.75 / (12*100); // Monthly Interest
  41. Months = 30 * 12; // Mortgage Length
  42. MonthlyPayment = 0; // Monthly Payment
  43.  
  44. // Calculate Monthly Payment
  45. MonthlyPayment = PrincipleBalance * (MonthlyInterest / (1 - Math.pow(1/(1+MonthlyInterest), Months)));
  46.  
  47. // Round Cent Decimal
  48. DecimalFormat RoundtoCents = new DecimalFormat("0.00");
  49.  
  50. //Output Calculation
  51. System.out.println();
  52. System.out.println("\t\t\tMcBride Financial Services");
  53. System.out.println("\t\t Monthly Mortgage Payment Calculator");
  54. System.out.println();
  55. System.out.println();
  56. System.out.println("\t\t\tPrincipal Mortgage: $"+Math.round(PrincipleBalance)+".");
  57. System.out.println("\t\t\tInterest Rate: "+MonthlyInterest*12*100+"%.");
  58. System.out.println("\t\t\tTerm: "+Months/12+" years");
  59. System.out.println();
  60. System.out.println();
  61. System.out.println("\t\t\tMonthly Payment: $"+RoundtoCents.format(MonthlyPayment)+".");
  62. System.out.println();
  63. }
  64. private int Period; //Instance variables
  65. private double LoanAmount;
  66. private double MonthlyInterestRate;
  67. private double MonthlyPayment;
  68. int Months;
  69. double PrincipleBalance, MonthlyInterest;
  70.  
  71. //constructor for user defined values
  72. public MortgagePaymentCalc4(int _Period, double LA, double IR){
  73. Period = _Period;
  74. LoanAmount = LA;
  75. MonthlyInterestRate = IR/12;
  76. // Initialize Variables
  77. PrincipleBalance = 200000; // Mortgage Amount
  78. MonthlyInterest = 5.75 / (12*100); // Monthly Interest
  79. Months = 30 * 12; // Mortgage Length
  80. MonthlyPayment = 0; // Monthly Payment
  81. }
  82.  
  83. public int GetPeriod(){
  84. return Period;
  85. }
  86. public void SetPeriod(int Period){
  87. this.Period = Period;
  88. }
  89.  
  90. public double GetLoanAmount(){
  91. return LoanAmount;
  92. }
  93. public void SetLoanAmount(double LoanAmount){
  94. this.LoanAmount = LoanAmount;
  95. }
  96.  
  97. public double GetMonthlyInterestRate(){
  98. return MonthlyInterestRate;
  99. }
  100. public void SetMonthlyInterestRate(double InterestRate){
  101. this.MonthlyInterestRate = InterestRate/12;
  102. }
  103. public void CalcMonthlyPayment(){
  104. MonthlyPayment = LoanAmount*Math.pow(1+MonthlyInterestRate, Period)*MonthlyInterestRate/(Math.pow(1+MonthlyInterestRate, Period) -1);
  105. }
  106. public String ToString (double value){
  107. return Double.toString(value);
  108. }
  109. public void DisplayMonthlyPayment(){
  110. System.out.println("Monthly Payment = $" +ToString(MonthlyPayment));
  111. }
  112.  
  113. public void listPrincipleBal()
  114. {
  115.  
  116. System.out.println();
  117. System.out.println("Month " + "\t" + "Amount " + "\t\t" + "Interest " + "\t" + "Balance ");
  118.  
  119. // Declare Variables
  120. int periods = 1, Months;
  121. double Balance, Interest, MonthlyPayment, PrincipleBalance, MonthlyInterest;
  122.  
  123. // Initialize Variables
  124. PrincipleBalance = 200000; // Mortgage Amount
  125. MonthlyInterest = 5.75 / (12*100); // Monthly Interest
  126. Months = 30 * 12; // Mortgage Length
  127. MonthlyPayment = 0; // Monthly Payment
  128.  
  129. while(periods <=Months)
  130. {
  131. int i = 0;
  132. while(i <10)
  133. {
  134. Balance = PrincipleBalance*(1+MonthlyInterest) - MonthlyPayment; //Calculation of Balance
  135. Interest = PrincipleBalance*MonthlyInterest; //Calculation of Interest
  136. //Now print using the round to two decimal places
  137. 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));
  138. PrincipleBalance = Balance; //Set the Principal for next round to the Balance of previous month
  139. periods++;
  140. i++;
  141. }
  142. System.out.println("Press Enter to continue..");
  143. BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
  144. String str = "";
  145. try
  146. {
  147. str = br.readLine();
  148. }
  149. catch (IOException ioe) { System.out.println(ioe); }
  150. }
  151. }
  152.  
  153. {
  154.  
  155. MortgagePaymentCalc4 mc3 = new MortgagePaymentCalc4(25, (double)200000, (double)0.0575);
  156.  
  157. //Calculate Monthly payment
  158. mc3.CalcMonthlyPayment();
  159. //Show the output
  160. mc3.DisplayMonthlyPayment();
  161. mc3.listPrincipleBal();
  162. }
  163. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: Jessica892 is an unknown quantity at this point 
Solved Threads: 0
Jessica892 Jessica892 is offline Offline
Newbie Poster

Re: Cannot find sybol Constructor and Methods

 
0
  #5
Jan 9th, 2008
I guess no one knows how to do this. I just turned it in not working, instructor wouldn't help me, classmates wouldn't help me, oh well.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Cannot find sybol Constructor and Methods

 
0
  #6
Jan 9th, 2008
You learn by your mistakes.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum


Views: 1881 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC