Friday, July 01, 2005

Convierte de números Arábicos a Romanos

package numeros;

public class NumRom {

public NumRom() {
super();
}

public static String convercion(int num) {
int[] arab = {1,5,10,50,100,500,1000};
String[] rom = {"I","V","X","L","C","D","M"};
StringBuffer sb = new StringBuffer();

for(int i = 6; i > = 0 ;i--)
while( num > = arab[i] ){
num -= arab[i];
sb.append(rom[i]);
}
return sb.toString();
}
}

0 Comments:

Post a Comment

<< Home