Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- * esTo Es UN CHOnizadoR quE te coNvieRTe frases al esTilO Choni
- *
- * htTp://twitTer.CoM/nRikEe93
- *
- * @author nRikee93
- * @version 1.0
- */
- public class Chonizador {
- public static void main (String args[]){
- Scanner teclat = new Scanner(System.in);
- String frase = new String();
- System.out.println("Introdueix la frase a chonizar");
- frase=teclat.nextLine();
- int part1;
- String part = new String();
- String partChonizada = new String();
- String part2 = new String();
- String chonizador = new String();
- int iteracio=0;
- /**Llevar espais en blanc*/
- int historial[] = new int[frase.length()];
- int historialH[] = new int[frase.length()];
- int x=0;
- int h=0;
- for (int n=0;n<frase.length();n++)
- {
- if(frase.charAt(n)==' ') {
- historial[x] = n;
- x++;
- }
- if(frase.charAt(n)=='h') {
- historialH[h] = n;
- h++;
- }
- }
- chonizador = frase.trim();
- /**Chonizar*/
- do{
- part1 = 2+(int) (Math.random()*(frase.length()-2));
- part = chonizador.substring(0,part1);
- partChonizada = chonizador.substring (part1,part1+1);
- part2 = chonizador.substring(part1+1);
- chonizador = part + partChonizada.toUpperCase() + part2;
- iteracio++;
- } while (iteracio < (int) (frase.length()*0.4));
- String chon = new String("");
- /**Afegir els espais en blanc*/
- for (int q=0;q<=x;q++)
- {
- chon= chonizador.substring(0,historial[q]) + " " + frase.charAt(historial[q]) + chonizador.substring(historial[q]+1);
- }
- System.out.println(chon);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement