Write Java Program, How To Convert Decimal Number To Roman Number?

2

2 Answers

Anonymous Profile
Anonymous answered
Write c++ program how to convert decimal number to roman number
Garvit Agrawal Profile
Garvit Agrawal answered
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);
    }  
}

Answer Question

Anonymous