I was looking for a tool to check if a given String is a valid roman numeral or not. Remember old Math? Like IV = 4, or V = 5 or X1 = 11 and so on. I got lucky and chanced upon this link. I did a little modification to cater the code to my needs. This class has 2 public methods namely getRomanNumeral and isRomanNumeral.

getRomanNumeral takes in an int parameter and converts it to its roman numeral equivalent. If the value is less than 1 or greater than 3,999, it throws a NumberFormatException. isRomanNumeral meanwhile, takes in a String parameter and checks if the given data is a valid roman numeral or not. It’s a great helper class to handle roman numeral issues.

Related Posts Plugin for WordPress, Blogger...