Advertisement
nomeUser0101324

TelepatiX

Jul 12th, 2020
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Random;
  3.  
  4. public class ContagemTelepatix {
  5.  
  6.     public static void main(String[] args) {
  7.        
  8.         Random t = new Random();
  9.         double erro = 0.01; //0.03; 0.05; 0.1; 0.15; 0.20; 0.5
  10.            
  11.        
  12.         HashMap<String, Integer> hashLetras = new HashMap<String, Integer>();
  13.  
  14.         hashLetras.put("A", 2); hashLetras.put("B", 3); hashLetras.put("C", 4); hashLetras.put("D", 5); hashLetras.put("E", 3);
  15.        
  16.         hashLetras.put("F", 4); hashLetras.put("G", 5); hashLetras.put("H", 6); hashLetras.put("I", 4); hashLetras.put("J", 5);
  17.        
  18.         hashLetras.put("K", 6); hashLetras.put("L", 7); hashLetras.put("M", 8); hashLetras.put("N", 9); hashLetras.put("O", 5);
  19.        
  20.         hashLetras.put("P", 6); hashLetras.put("Q", 7); hashLetras.put("R", 8); hashLetras.put("S", 9); hashLetras.put("T", 10);
  21.        
  22.         hashLetras.put("U", 6); hashLetras.put("V", 7); hashLetras.put("W", 8); hashLetras.put("X", 9); hashLetras.put("Y", 10);
  23.        
  24.         hashLetras.put("Z", 11); hashLetras.put(" ", 7); //ESPACO
  25.  
  26.         String teste="PODE FALAR MAIS DEVAGAR POR FAVOR";
  27.  
  28.         int count = 0;
  29.  
  30.         for (int i = 0; i < teste.length(); i++) {
  31.  
  32.             if (i < (teste.length() - 1) && teste.charAt(i) == 'Q' && teste.charAt(i + 1) == 'U') {
  33.                 if (t.nextDouble() > erro) {
  34.                     count = count + 7;
  35.                     i++;
  36.                 } else {
  37.                     count = count + 7 + 9; // são 9 segundos para corrigir [apagar] cada letra
  38.                     i++;
  39.                 }
  40.             } else {
  41.                 if (t.nextDouble() > erro) {
  42.                     String c = teste.charAt(i) + "";
  43.                     count = count + hashLetras.get(c);
  44.                 } else {
  45.                     String c = teste.charAt(i) + "";
  46.                     count = count + 9 + hashLetras.get(c); // são 9 segundos para corrigir [apagar] cada letra
  47.                 }
  48.             }
  49.         }
  50.  
  51.         System.out.println("O tempo foi de: "+count);
  52.     }
  53.    
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement