added declarations, implementations, and cin/cout in Main