Programming Assignment #2 solution implementation

Given this is part of a course to learn R, Code is heavily commented