import java.io.*;
public class test {
public static void main
(String args
[]) { int i, j;
Array[] c =
new Array[50];
//Store the letters info for (i = 0; i < 50; i++) {
c[i].ch = 0;
c[i].times = 0;
c[i].per = 0;
}
try{
System.
out.
println("Please input the string: ");
s = br.readLine();
for (i = 0; i < s.length(); i++) {
for (j = 0; j < 50; j++) {
if (c[j].times == 0) {
c[j].ch = s.charAt(i);
c[j].times++;
break;
}
else if (c[j].ch == s.charAt(i)) {
c[j].times++;
break;
}
else continue;
}
}
System.
out.
println(c
[42].
times);
for (i = 0; i < 100 && c[i].times != 0; i++) {
c[i].per = c[i].times/s.length();
}
Sort.sort(c);
for (i = 0; i < 100 && c[i].times != 0; i++) {
System.
out.
println("'s percentage is "+c
[i
].
per);
}
}
}
char ch; //the letter
int times; //the times
float per; //the percentage
}
class Sort {
static void sort
(Array[] c
) { int pass, i;
for (pass = 1; pass < 50 && c[pass].times != 0; pass++) {
temp.ch = c[pass].ch;
temp.times = c[pass].times;
temp.per = c[pass].per;
for (i = pass-1; i >= 0; i--)
if (c[i].times > temp.times) break;
else {
c[i+1].ch = c[i].ch;
c[i+1].times = c[i].times;
c[i+1].per = c[i].per;
}
c[i+1].ch = temp.ch;
c[i+1].times = temp.times;
c[i+1].per = temp.per;
}
}
}