my first program in Java, functional but full of redundancies and syntax errors