Skip to content

Commit

Permalink
Merge pull request #5991 from moguism/main
Browse files Browse the repository at this point in the history
Reto #47 - Java
  • Loading branch information
kontroldev authored Dec 8, 2023
2 parents 3d157fb + 85d4f0e commit d4e8b36
Showing 1 changed file with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import java.util.Scanner;

public class moguism {

public static void main(String[] args){

Scanner leer = new Scanner(System.in);

int puntos = 0;

String palabra = "";

while (puntos != 100) {

System.out.print("Introduce una palabra: ");
palabra = leer.next();

String copiaPalabra = palabra.toUpperCase();

for(int i = 0; i < copiaPalabra.length(); i++){

int puntosLetra = 0;

for(int j = 65; j <= 90; j++){ // Empieza en la A y termina en la Z (en ASCII)

puntosLetra++;

if(j == 78){ // Cuando llega a la Ñ

puntosLetra++;

}

if(copiaPalabra.charAt(i) == j){

puntos = puntos + puntosLetra;
break;

} else if(copiaPalabra.charAt(i) == 'Ñ'){

puntos = puntos + puntosLetra;
break;

}

}

}

System.out.println("La palabra "+palabra+" vale "+puntos+" puntos");

if(puntos != 100){

puntos = 0;

}


}

System.out.println("¡ENHORABUENA!");

leer.close();

}
}

0 comments on commit d4e8b36

Please sign in to comment.