Вы находитесь на странице: 1из 2

NOMBRE: CINDIA ORTIZ YBARRA.

PROFESOR: OTONIEL GONZALES


MATERIA: FUNDAMENTOS DE
PROGRAMACION
CENTRO: UNIDEG SAN FELIPE
Del siguiente arreglo

O T O N I E L

Obtener el valor numérico de la palabra que contiene el arreglo

package actividad.pkg9;
public class actividad9 {
public static void main(String[] args) {
char [] A={'O','T','O','N','I','E','L'};
int r,acumulador=0;
for (r=0; r<A.length; r=r+1)
{if (A[r]=='A'){acumulador=acumulador+1;}
if (A[r]=='B'){acumulador=acumulador+2;}
if (A[r]=='C'){acumulador=acumulador+3;}
if (A[r]=='D'){acumulador=acumulador+4;}
if (A[r]=='E'){acumulador=acumulador+5;}
if (A[r]=='F'){acumulador=acumulador+6;}
if (A[r]=='G'){acumulador=acumulador+7;}
if (A[r]=='H'){acumulador=acumulador+8;}
if (A[r]=='I'){acumulador=acumulador+9;}
if (A[r]=='J'){acumulador=acumulador+10;}
if (A[r]=='K'){acumulador=acumulador+11;}
if (A[r]=='L'){acumulador=acumulador+12;}
if (A[r]=='M'){acumulador=acumulador+13;}
if (A[r]=='N'){acumulador=acumulador+14;}
if (A[r]=='Ñ'){acumulador=acumulador+15;}
if (A[r]=='O'){acumulador=acumulador+16;}
if (A[r]=='P'){acumulador=acumulador+17;}
if (A[r]=='Q'){acumulador=acumulador+18;}
if (A[r]=='R'){acumulador=acumulador+19;}
if (A[r]=='S'){acumulador=acumulador+20;}
if (A[r]=='T'){acumulador=acumulador+21;}
if (A[r]=='U'){acumulador=acumulador+22;}
if (A[r]=='V'){acumulador=acumulador+23;}
if (A[r]=='W'){acumulador=acumulador+24;}
if (A[r]=='X'){acumulador=acumulador+25;}
if (A[r]=='Y'){acumulador=acumulador+26;}
if (A[r]=='Z'){acumulador=acumulador+27;}}
System.out.println(acumulador);}}

Вам также может понравиться