import java.util.Scanner;
public class JmlPola{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
System.out.print("masukkan string : ");
String input = sc.nextLine();
System.out.println("Ada "+input.length()+" pola");
int pisah = 0;
int jml=0;
int jmlKata = 0;
String[] temp = new String[input.length()];
String[] tampung;
while(pisah<=0||pisah>input.length()){
System.out.print("Pilih pola pisah berapa huruf?: ");
pisah = sc.nextInt();
}
System.out.println ("");
System.out.println ("Pola Yang dihasilkan adalah :");
for(int j = 0; j <= input.length() - pisah; j++){
temp[j]= input.substring(j,j+pisah);
System.out.print(temp[j]+" ");
jmlKata++;
}
System.out.println (" ");
System.out.println (" ");
System.out.println ("Dengan Frekwensi :");
tampung = new String [jmlKata];
for (int i=0; i
boolean ketemu = false;
int j=0;
for(j=0; j
if (temp[i].equals(tampung[j]))
ketemu=true;
}
if (!ketemu){
tampung[jml]=temp[i];
jml++;
}
}
for (int i=0; i
int sum = 0;
for(int j=0; j
if(tampung[i].equals(temp[j]))
sum++;
}
System.out.println (tampung[i]+" = "+sum);
}
}
}
Untuk Source Code Lengkap bisa didownload di sini : DOWNLOAD
0 comments:
Post a Comment