Ported initial console Java code into Scala