completed code for Program 2