dan ini adalah source codenya :
import java.util.Scanner;
public class charCount{
public static void main (String [] args){
Scanner sc = new Scanner(System.in);
String temp = "";
System.out.print("Masukkan kata : ");
String input = sc.nextLine().toLowerCase();
for(int i = 0; i < input.length(); i++){
boolean exist = false;
for (int j = 0; j < temp.length(); j++){
if(input.charAt(i)==temp.charAt(j)){
exist = true;
}
}
if(!exist){
temp = temp + input.charAt(i);
}
}
System.out.println();
System.out.println("Himpunan huruf dari inputan : "+temp);
System.out.println();
System.out.println("Frekuensi @ huruf :");
for (int i = 0; i < temp.length(); i++){
int sum = 0;
for(int j = 0; j < input.length(); j++){
if(temp.charAt(i)==input.charAt(j)) sum++;
}
if(temp.charAt(i)==' ') System.out.println("
else System.out.println(temp.charAt(i)+" = "+sum);
}
}
}
source juga bisa di download di sini : DOWNLOAD
0 comments:
Post a Comment