Improved error handling and some code formatting.

Got rid of the redundant catch-throw statements which just mess up good error messages, switched if-else to switch over strings, and added NumberFormatException for when input is not formatted correctly.