ProgAsssingment2 solution