Java Examples

Fibonnaci Number

Java 3.12.2010 2 Comments

Generating Fibonacci numbers is an assignment often given to Java students when they are being introduced to recursion. Recursion is programming technique that involves a method calling itself to solve a problem. When implementing a recursive solution we look for two things: A base case that returns a value without any subsequent recursive calls. A…

Read More

Calculator Keypad

Java, Swing 14.8.2010 No Comments

This problem involves understanding some of the basics of building a Swing application including how individual components are laid out inside a window, and how your application can react to the user interacting with the application. In this case we need to update a text field whenever a button is pressed. The key points to…

Read More

Simple Mortgage Calculator

Simple Mortgage Calculator

This example expands on the Monthly Payment Calculator example we posted earlier. As well as calculating the monthly payment for a loan, it then goes on to use that to calculate the balance of the loan after each payment. This is often referred to as an amortisation schedule. The displayMonthlyBalance() method handles generating the schedule…

Read More

Monthly Payment Calculator

Java 2.6.2010 1 Comment

This is the simplest form of one of the classic problems given to first year Java students. It aims to get you comfortable with the structure of a simple Java application and how to get input from the user. User input in this example is taken from the console (standard input). The Scanner class comes…

Read More
s2Member®