Get roman numeral representation of the int @param num the int @return the numerals
(int num)
| 1248 | * @return the numerals |
| 1249 | */ |
| 1250 | public static String toRoman(int num) { |
| 1251 | |
| 1252 | String res = ""; |
| 1253 | |
| 1254 | for (Map.Entry<String, Integer> entry : roman_numerals.entrySet()) { |
| 1255 | int matches = num / entry.getValue(); |
| 1256 | |
| 1257 | res += repeat(entry.getKey(), matches); |
| 1258 | num = num % entry.getValue(); |
| 1259 | } |
| 1260 | |
| 1261 | return res; |
| 1262 | } |
| 1263 | |
| 1264 | /** |
| 1265 | * Get the number representation from roman numerals. |
no test coverage detected