Skip to content

Instantly share code, notes, and snippets.

@valterh4ck3r
Created March 8, 2018 19:33
Show Gist options
  • Save valterh4ck3r/ef5840cfb1d1adf8b3cd336ba56f5c22 to your computer and use it in GitHub Desktop.
Save valterh4ck3r/ef5840cfb1d1adf8b3cd336ba56f5c22 to your computer and use it in GitHub Desktop.
Converter Inteiro para Romano
public static String parseNumeroRomano(Integer num) {
String M[] = {"", "M", "MM", "MMM"};
String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return M[num / 1000] + C[(num % 1000) / 100] + X[(num % 100) / 10] + I[num % 10];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment