Completed program for assignment