Modified the logic of sample program, added menu.
Increased redundancy and removed trailing whitespace.