solved programming assignment 2