I am new to the world of Java (been learning for almost seven weeks now). Every time I start thinking I might be getting the hang of this object-oriented world, I am brought back down to Earth.
Please help a Java noob with some advice
Moderator: Community Moderator
- Wadini
- Soldier First Class

- Posts: 17
- Joined: 10 Jan 2010, 02:42
- Location: Precariously perched upon a precipice
- Has thanked: 6 times
Please help a Java noob with some advice
Hi everyone!
I am new to the world of Java (been learning for almost seven weeks now). Every time I start thinking I might be getting the hang of this object-oriented world, I am brought back down to Earth.
I am learning how to build a GUI now, and I am confused about an assignment.
It is the "standard" create a mortgage calculator type of program. Is it better to approach this type of application from a particular perspective? For example, should I build my GUI first (i.e. construct all of my javax.swing & java.awt components first)? Then build any classes to cover the mathematics? Or, should I build my math (logic) classes, and then my GUI? Getting started on this application has me a bit confused. I feel a bit like I am trying to answer the "which came first, the chicken or the egg" question on this assignment. Could be that I am over-thinking and making it harder than it needs to be. I have been known to do that!
One other question, are there any "best resources" for Java that anyone could recommend for me?
Thanks for any insight and/or advice, it is greatly appreciated!
I am new to the world of Java (been learning for almost seven weeks now). Every time I start thinking I might be getting the hang of this object-oriented world, I am brought back down to Earth.
- ChattChitto
- Site Admin

- Posts: 13868
- Joined: 20 Aug 2009, 06:20
- Status: The Don
- Location: The Fourth Dimension
- Has thanked: 11 times
- Been thanked: 38 times
- Contact:
Re: Please help a Java noob with some advice
Start with the GUI, check what inputs should be made, what outputs should be displayed.
Once you figure these out create the GUI (don't forget the calculate buttons etc..). now comes the functionality:
Place the functionality inside each specified button. this way you can test each function by itself.
Use NetBeans in this process.
If you need more help you must share more information about your project (the requirements and functionality)
Once you figure these out create the GUI (don't forget the calculate buttons etc..). now comes the functionality:
Place the functionality inside each specified button. this way you can test each function by itself.
Use NetBeans in this process.
If you need more help you must share more information about your project (the requirements and functionality)
To err is human, to forgive is divine
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
ChattChitto RG - Apps Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=104
ChattChitto RG - Movies Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=5092
ChattChitto RG - Music Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=34836
- ChattChitto
- Site Admin

- Posts: 13868
- Joined: 20 Aug 2009, 06:20
- Status: The Don
- Location: The Fourth Dimension
- Has thanked: 11 times
- Been thanked: 38 times
- Contact:
Re: Please help a Java noob with some advice
I've done for you the GUI. I don't know if these are the exact required fields but you'll have an Idea:

To err is human, to forgive is divine
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
ChattChitto RG - Apps Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=104
ChattChitto RG - Movies Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=5092
ChattChitto RG - Music Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=34836
- MicroLife
- Uploader

- Posts: 438
- Joined: 31 Oct 2010, 14:20
- Location: Omnipresent
- Has thanked: 2 times
- Been thanked: 1 time
- Contact:
Re: Please help a Java noob with some advice
if i ever hav any ques abt programming i'll consult u before asking my profsChattChitto wrote:I've done for you the GUI. I don't know if these are the exact required fields but you'll have an Idea:
- Wadini
- Soldier First Class

- Posts: 17
- Joined: 10 Jan 2010, 02:42
- Location: Precariously perched upon a precipice
- Has thanked: 6 times
Re: Please help a Java noob with some advice
Thank you ChattChitto, that is a GREAT GUI!!!
Placing the functionality in the component after the GUI is built makes perfect sense after seeing what you are saying. For my assignment, I actually only need the loan amount, the interest rate, and the term. The application is to calculate the monthly payments. The actual assignment states: I will have to add functionality to the application over the coming weeks. I will work on this program today, and I do have NetBeans. Do you use the GUI builder in NetBeans, and do you import swing.BorderFactory for those boxes and borders? Thanks, you're a great help! 
Spoiler: show
- ChattChitto
- Site Admin

- Posts: 13868
- Joined: 20 Aug 2009, 06:20
- Status: The Don
- Location: The Fourth Dimension
- Has thanked: 11 times
- Been thanked: 38 times
- Contact:
Re: Please help a Java noob with some advice
Then please let me know the exact boxes for Input and the ones for output 
I consider now that input boxes should be: Loan Amount | Annual Interest Rate | Term
and the output results should stay as is?
you can provide me with the formula of calculation if you wish too
I consider now that input boxes should be: Loan Amount | Annual Interest Rate | Term
and the output results should stay as is?
you can provide me with the formula of calculation if you wish too
To err is human, to forgive is divine
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
ChattChitto RG - Apps Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=104
ChattChitto RG - Movies Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=5092
ChattChitto RG - Music Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=34836
- Wadini
- Soldier First Class

- Posts: 17
- Joined: 10 Jan 2010, 02:42
- Location: Precariously perched upon a precipice
- Has thanked: 6 times
Re: Please help a Java noob with some advice
I am definitely having some problems with this code.
The inputs and outputs should be just as you said in your last post. I was hoping to have two buttons, Calculate and Reset (for user to clear information and start over). I have not been able to make nearly as much progress as I was hoping for ...maybe it is the addition of the GUI components that is confounding me (I don't know). I also can't get a GUI to look nearly as good as yours ChattChitto. The formula for calculation that I have determined is as follows:
Any guidance that you could give is very appreciated. I cannot thank you enough for your help, but please know that I really appreciate it. All of your assistance and advice helps me to learn, and hopefully be able to help others when I become able.
Code: Select all
public void CalculateMonthPayment()
{
//For a standard loan with interest
if (interestRate > 0)
{
monthInterest = interestRate / (100.00 * 12.00);
monthPayment = principalBalance * ((monthInterest * (Math.pow((1 + monthInterest), loanTerm)))
/ (Math.pow((1 + monthInterest), loanTerm) - 1));
} else
{
monthPayment = principalBalance / loanTerm; //For an interest free loan
}
}
- ChattChitto
- Site Admin

- Posts: 13868
- Joined: 20 Aug 2009, 06:20
- Status: The Don
- Location: The Fourth Dimension
- Has thanked: 11 times
- Been thanked: 38 times
- Contact:
Re: Please help a Java noob with some advice
I've done it. but I think something might be wrong with what you game me.
If it was:
and you placed 1000$ for 1 Year. it will give you 1000 which is wrong.
it should be:
Please check everything and let me know. I don't like keep fixing small mistakes all the time as it would be too confusing 
If it was:
Code: Select all
monthPayment = principalBalance / loanTerm; //For an interest free loanit should be:
Code: Select all
monthPayment = principalBalance / (loanTerm*12); //For an interest free loanTo err is human, to forgive is divine
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
We can't all be heroes, because somebody has to sit on the curb and applaud when they go by.
ChattChitto RG - Apps Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=104
ChattChitto RG - Movies Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=5092
ChattChitto RG - Music Upload List: http://chattchitto.com/forum/viewtopic.php?f=29&t=34836
- Wadini
- Soldier First Class

- Posts: 17
- Joined: 10 Jan 2010, 02:42
- Location: Precariously perched upon a precipice
- Has thanked: 6 times
Re: Please help a Java noob with some advice
Mine is certainly not pretty, but all functionality is working now.
I was so tired by the time I finished, that I left off the "Total Payments" function. The line of code for interest free:
has already been converted to months earlier in the program (I should have mentioned that
):
Could you take a look at the "finished" code for me, and maybe give me some help to get it looking more like your GUI?
To save space, I will collapse the code in a spoiler box.
If you see anything (syntax, structure, format, anything) that I should change for better programming, please let me know. I want, very much, to learn these concepts the best way possible. Thank you * 1,000,000!

Code: Select all
monthPayment = principalBalance / loanTerm; //For an interest free loanCode: Select all
double loanTerm = Double.parseDouble(termText.getText()) * 12;
AssignTerm(loanTerm);
Spoiler: show