• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loan Amortization Table for Loan Payment Calculator  RSS feed

 
Justin Fondriest
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//The following is an assignment I need to do. I MUST start by saying I do not want the answer
//(someone tried to write a program for me last time I asked a question and I did not even look at
// it). However, I am hoping to find some idea of how to move forward with this assignment in a
//way that makes it easy to add onto the program in later weeks. THAT is the core precept
//behind my reason for posting here.
///////////////////////////////////////...
//
//Here is the Assignment:
//
//Add a method to the Class defined in the week 2 individual assignment. The method should
//print a loan amortization. Program the print function to use loops to keep the display from
//scrolling off of the screen (50 lines). Resume the display when the enter key is depressed. An
//example of a loan amortization is posted in the material forum.
//
//Insert comments in the program to document the program.
//
///////////////////////////////////////...
//
//The following is my previously created Code for TWO different classes I have created:
//
//1st Class:
///////////////////////////////////////...



///////////////////////////////////////...
//
//SECOND Class:
//
///////////////////////////////////////...


///////////////////////////////////////...

1st: Do I need to add a method onto the class? If so, does the method I already added require changing?

2nd: Could someone help me with the Pseudocode? That is where I need the help. Thanks a great deal!

3rd: I have read NOWHERE in our text book about using the Enter Button to page through the contents...
Have plenty of time to figure this out (about 3-4 days)...
But want to get ahead of it and learn it well before I have to worry...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin,
Welcome to CodeRanch! You are going to like it better here than wherever you posted last time. We aren't about writing programs for people. We are about learning which is exactly what you are asking for. Speaking of which, I edited your post to add code tags around the code to make it easier to read. Next time you post, you can do it yourself - just highlight the code and click the "code" button above this textarea.

1) You do need to add a method. Since the assignment doesn't say to create another class, I think they mean for you to add it in the original class.

2) The assignment asks you to have the function print a value, not return it. It also asks you to keep track of how many times you have printed a line. Do you know what type of variable you could use to do this? In particular, do you know why a local (method) variable won't do the trick? Forget about Java for a moment. Can you describe the problem in your own words?

3) System.in and read or System.console().readLine() will let you read when the user presses enter. (or any other key).
 
Justin Fondriest
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Justin,
Welcome to CodeRanch! You are going to like it better here than wherever you posted last time. We aren't about writing programs for people. We are about learning which is exactly what you are asking for. Speaking of which, I edited your post to add code tags around the code to make it easier to read. Next time you post, you can do it yourself - just highlight the code and click the "code" button above this textarea.

1) You do need to add a method. Since the assignment doesn't say to create another class, I think they mean for you to add it in the original class.

2) The assignment asks you to have the function print a value, not return it. It also asks you to keep track of how many times you have printed a line. Do you know what type of variable you could use to do this? In particular, do you know why a local (method) variable won't do the trick? Forget about Java for a moment. Can you describe the problem in your own words?

3) System.in and read or System.console().readLine() will let you read when the user presses enter. (or any other key).



In response to 1), In week 2 I was supposed to add a second class to perform the function of calculating the monthly payment.

In response to 2), I was returning the value from that class back to the main class (probably not the best way, but we only get to see our professor 1 time per week). Not sure if I can move forward with this assignment as it has been completed currently but am more than willing to keep at it to change it as appropriate. He is not expecting professional quality, and I know it will be difficult to reach that level in the 5 week introductory course, but I would like to get this working in a way that will produce less work as I add onto it in the upcoming weeks. This, I am sure, is likely what professional programmers aim for regardless...so it is probably smart to work on Learning the most EFFICIENT way to do this. The professor is relatively flexible, however, so long as the assignment gets him the result he wants to see (probably because he tends to confuse us when he talks about what he wants in class...and then we see what he wants on the syllabus).

In response to ), thanks for the advice. I will go google those and see what I can find.


Do you guys have a chat room in here by chance? or any other means of conversation other than the forums? something more real-time? I am really wanting to learn this stuff but it seems I have difficulty actually taking the concepts and transforming them into new programs.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
You have some very old‑fashioned programming if you are using JOptionPane for keyboard input rather than Scanner. You can have problems with any sort of keyboard input if you enter the wrong format, but Scanner has a fiddle which Rob Spoor pointed out to me ages ago. You will be using keyboard input all the time, so I suggest you create yourself a utility class to handle it; there is an incomplete example in this thread. Only it ought to be called KeyboardInputs as a utility class. Note all members of a utility class are static and it has a private constructor to prevent anybody creating an instance. (You never need an instance of a utility class.) You will obviously have to enlarge what I wrote there. You can even have methods which insist on maximum and minimum values for your values, so you can call them like this:-One of those calls will produce the wrong result or go into an infinite loop because you have the maximum less than the minimum . I am sure you are able to create such a class with nextDouble…() ,methods for yourself in an hour, and that hour now will save you many hours of writing keyboard input instructions in future. That code can be relied upon not to throw any Exceptions, and will keep going until you give it correct input.
There is a pitfall with Scanner and its nextLine() method. Somebody else had problems here, so read that. You often need to discard nextLine after nextAnythingElse. A lot of books misunderstand nextLine(), so it is difficult to find out about that pitfall.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please consider the class you are writing. You are not creating an object of it. I think you should call it Loan, with amount, term and interest fields. You can consider whether to make the method which calculates the regular payment static or non‑static (=instance method). If it is an instance method it takes the values directly from its fields.
If you have a Loan class, you can enhance it with a field recording how much has been repaid. The solution with all static methods does not lend itself to such enhancement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!