Cleaned up Java code, broke the computation into its own class to perform the parsing and formatting of the output strings.