Write c++ program how to convert decimal number to roman number
Class Decimal_to_Roman
{
public static void main(int decimal)
{
String[] RCODE = {"M", "CM", "D", "CD", "C", "XC", "L","XL", "X", "IX", "V", "IV", "I"};
int[] DVAL = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
String roman = "";
for (int I = 0; I < RCODE.length; I++)
{
while (decimal >= DVAL[I])
{
decimal -= DVAL[I];
roman += RCODE[I];
}
}
System.out.println(roman);
}
}
{
public static void main(int decimal)
{
String[] RCODE = {"M", "CM", "D", "CD", "C", "XC", "L","XL", "X", "IX", "V", "IV", "I"};
int[] DVAL = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
String roman = "";
for (int I = 0; I < RCODE.length; I++)
{
while (decimal >= DVAL[I])
{
decimal -= DVAL[I];
roman += RCODE[I];
}
}
System.out.println(roman);
}
}