program for Pset1 in Java