You have been given an algorithm of sorts in the description. Implement each line in Java and add bits to it
to make it work correctly. Do one small part at a time, test that and make sure it works...