Skip to content

Commit

Permalink
Reto #47 - Java
Browse files Browse the repository at this point in the history
  • Loading branch information
Qv1ko committed Dec 7, 2023
1 parent 1561c8a commit d9d52cb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/java/Qv1ko.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.HashMap;
import java.util.Scanner;

class Qv1ko {

public static void main(String[] args) {
wordPoints();
}

private static void wordPoints() {

HashMap<Character, Integer> letterPoints = new HashMap<Character, Integer>() {{ put('a', 1);put('b', 2); put('c', 3); put('d', 4); put('e', 5); put('f', 6); put('g', 7); put('h', 8); put('i', 9); put('j', 10); put('k', 11); put('l', 12); put('m', 13); put('n', 14); put('ñ', 15); put('o', 16); put('p', 17); put('q', 18); put('r', 19); put('s', 20); put('t', 21); put('u', 22); put('v', 23); put('w', 24); put('x', 25); put('y', 26); put('z', 27); }};
String word = "";
int points = 0;
Scanner sc = new Scanner(System.in);

while (points != 100) {

points = 0;

System.out.print("Type a word: ");
word = sc.nextLine().toLowerCase();

for (char letter : word.toCharArray()) {
points += letterPoints.get(letter);
}

System.out.println("The word " + word + " has " + points + " points");

}


sc.close();

}

}

0 comments on commit d9d52cb

Please sign in to comment.