Integer to Roman Number Converter

java
public class Roman { final static String[][] romans = new String[][]{ new String[]{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}, new String[]{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}, new String[]{"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}, new String[]{"", "M", "MM", "MMM", "MMMM"} }; public static String answer(int number) { char[] rNumber = new StringBuilder(""+number).reverse().toString().toCharArray(); String output = ""; for(int i = rNumber.length-1; i >= 0; i--) output += romans[i][rNumber[i]-48]; return output; } }

Reference

No known

History Nov 06, 2017