updated problem4.java