Added a function that used up nearly all of the remaining parts of the flow chart requirements and some additional outputs to the main code.