I've been trying to do this problem but I can not finish it enter int and write it in letter
Example
150 == one hundred fifty
My biggest problem is that I get compile error when trying to print the vectors of numbers, I guess that is because the control variable ( aux1 ) is not int , or I did not know how to convert
This is my breakthrough:
String unidades [] = {"uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve"};
String decenas []= {"diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa"};
String centenas []= {"ciento", "docientos", "trecientos", "cuatrocientos", "quinientos", "seicientos", "setecientos", "ochocientos", "novecientos"};
String unidad_m []= {"mil", "dosmil", "tresmil", "cuatromil", "cincomil", "seismil", "sietemil", "ochomil", "nuevemil"};
String decena_m []= {"once", "doce", "trece", "catorce", "quince", "dieciseis", "dieciciete", "dieciocho", "diecinueve"};
int num, aux1;
char aux;
System.out.println("escribe un numero");
num = var.nextInt();
String numero, numero2;
numero=Integer.toString(num);
numero2 = numero;
char vec [] = numero2.toCharArray();
//una disculpa, hay algunas cariables basura
for (int i = vec.length-1; i > -1; i--) {
aux = vec [i];
aux1 = (int)aux;
System.out.println(aux);
if(vec.length==4){
System.out.print(decena_m[aux1]);
}else{
if(vec.length==3){
System.out.print(unidad_m[aux1]);
}else{
if(vec.length==2){
System.out.print(centenas[aux1]);
}else{
if(vec.length==1){
System.out.print(decenas[1]);
}else{
if(vec.length==0){
System.out.print(unidades[aux1]);
}
}
}
}
}
}