From d9d52cb568ce2a9af9e913ecce1908997ff51b9d Mon Sep 17 00:00:00 2001 From: Qv1ko Date: Thu, 7 Dec 2023 02:43:43 +0100 Subject: [PATCH] Reto #47 - Java --- .../java/Qv1ko.java" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/java/Qv1ko.java" diff --git "a/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/java/Qv1ko.java" "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/java/Qv1ko.java" new file mode 100644 index 0000000000..9f2b301e94 --- /dev/null +++ "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/java/Qv1ko.java" @@ -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 letterPoints = new HashMap() {{ 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(); + + } + +} \ No newline at end of file