I have the following code: it is to count how many seconds I take to type a sentence. If I type BABA the result is 10. BUT I WANTED THAT WHEN THERE WAS THE JUNCTION OF THE LETTER 'Q' + 'U', (AS IN THE WORD CHEESE), HE CONSIDERS A VALUE ONLY AND NOT THE VALUE OF 'Q' + VALUE DO 'U'.
OR BE, 'Q' IN THIS CASE IS VALLEY 7 AND U VALUE 6, I WANTED THE JUNCTION 'WHAT IS VALID ONLY 7, HAVE IT? TYPE: hashLetras.put ("QU", 7);
package solucao;
import java.util.HashMap;
public class Contagem {
public static void main(String[] args) {
HashMap<String, Integer> hashLetras=new HashMap<String, Integer>();
hashLetras.put("A", 2);
hashLetras.put("B", 3);
hashLetras.put("C", 4);
hashLetras.put("D", 5);
hashLetras.put("E", 3);
hashLetras.put("F", 4);
hashLetras.put("G", 5);
hashLetras.put("H", 6);
hashLetras.put("I", 4);
hashLetras.put("J", 5);
hashLetras.put("K", 6);
hashLetras.put("L", 7);
hashLetras.put("M", 8);
hashLetras.put("N", 9);
hashLetras.put("O", 5);
hashLetras.put("P", 6);
hashLetras.put("Q", 7);
hashLetras.put("R", 8);
hashLetras.put("S", 9);
hashLetras.put("T", 10);
hashLetras.put("U", 6);
hashLetras.put("V", 7);
hashLetras.put("W", 8);
hashLetras.put("X", 9);
hashLetras.put("Y", 10);
hashLetras.put("Z", 11);
hashLetras.put(" ", 7); //ESPACO
String teste="QUEIJO";
int count=0;
for(int i=0; i<teste.length();i++){
String c = teste.charAt(i)+ "";
count = count+hashLetras.get(c);
}
System.out.println("O tempo foi de: "+count);
}
}