java app for iteration 2