public class Solution {public String inttoroman (int num) {int[] digits = new INT[4]; int i = 0; String s = ""; Digits[i] = num%10; while (num = NUM/10) > 0) {digits[++i] = num%10; } for (int j = 0; J <= I; j + +) {if (j = = 0) {switch (Digits[j]) {CAs E 1:s = s + "I"; Break Case 2:s = s + "II"; Break Case 3:s = s + "III"; Break Case 4:s = s + "IV"; Break Case 5:s = s + "V"; Break Case 6:s = s + "VI"; Break Case 7:s = s + "VII"; Break Case 8:s = s + "VIII"; Break Case 9:s = s + "IX"; Break Default:break; }} else if (j = = 1) {switch (Digits[j]) {Case 1:s = "X" + S; Break Case 2:s = "XX" + S; Break Case 3:s = "XXX" + S; Break Case 4:s = "XL" + S; Break Case 5:s = "L" + S; Break Case 6:s = "LX" + S; Break Case 7:s = "LXX" + S; Break Case 8:s = "LXXX" + S; Break Case 9:s = "XC" + S; Break Default:break; }} else if (j = = 2) {switch (Digits[j]) {Case 1:s = "C" + S; Break Case 2:s = "CC" + S; Break Case 3:s = "CCC" + S; Break Case 4:s = "CD" + S; Break Case 5:s = "D" + S; Break Case 6:s = "DC" + S; Break Case 7:s = "DCC" + S; Break Case 8:s = "DCCC" + S; Break Case 9:s = "CM" + S; Break Default:break; }} else{switch (Digits[j]) {Case 1:s = "M" + S; Break Case 2:s = "MM" + S; Break Case 3:s = "MMM" + S; Break Default:break; }}} return s; }}
Jan 14-integer to Roman; String; Integer; Math;