My code for second programming assignment