Algorithmic programming in Java: code