Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Random;
- public class ContagemTelepatix {
- public static void main(String[] args) {
- Random t = new Random();
- double erro = 0.01; //0.03; 0.05; 0.1; 0.15; 0.20; 0.5
- 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="PODE FALAR MAIS DEVAGAR POR FAVOR";
- int count = 0;
- for (int i = 0; i < teste.length(); i++) {
- if (i < (teste.length() - 1) && teste.charAt(i) == 'Q' && teste.charAt(i + 1) == 'U') {
- if (t.nextDouble() > erro) {
- count = count + 7;
- i++;
- } else {
- count = count + 7 + 9; // são 9 segundos para corrigir [apagar] cada letra
- i++;
- }
- } else {
- if (t.nextDouble() > erro) {
- String c = teste.charAt(i) + "";
- count = count + hashLetras.get(c);
- } else {
- String c = teste.charAt(i) + "";
- count = count + 9 + hashLetras.get(c); // são 9 segundos para corrigir [apagar] cada letra
- }
- }
- }
- System.out.println("O tempo foi de: "+count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement