A common problem many new Java developers is to write a program that prints out a triangle. There a lots of variations on this problem but lets start with a simple case and then have a look at some possible variations. Probably the simplest case is a left aligned triangle of stars that looks like…

Read More
The Bubble Sort algorithm gets it’s name from the fact that on each pass, one element of the array ‘bubbles’ it’s way through to it’s correct (sorted) position in the array. Rather than me try and explain the details the following video gives a great visual demonstration of how the algorithm works. The source code…

Read More
The assignment here is to read a text file containing a list of numbers. We need to report how many numbers were in the file, the sum of all the numbers, the average of all numbers, and the minimum and maximum number. First step is to read the file and for this we can use…

Read More
A popular problem is how to determine if a String is a Palindrome or not, the following will also assume we are only dealing with Palindromes of single words ie. no spaces or punctuation. The way to determine this is to compare the characters on the left and right ends of the String. If they…

Read More
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