java applet front end for this classic interview question