I made a program that counts the number of occurrences of all the letters in a given String using TreeMap(String, Integer) (named alphaFreq). Now I want to represent these occurrences as percentages ([A=12.3] , [B=3.0] , ....etc), so I created another TreeMap (String, Double) (named percentage), copied all keys with their values set to zero, and edited the value according to that in alphaFreq as follows:
for(int i=0; i<26; i++){
int temp;
Character current = (char)(i+65);
String frog = current.toString();
temp = alphaFreq.get(frog);
int perc = (temp/cipherLetters.length)*100;
System.out.println(temp+"/"+cipherLetters.length+" = "+perc);
percentage.put(frog,(double)perc);
}
If the String is all As or Bs, the result is all keys have a value of zero except A=100.0 or B=100.0 But if the String text has any other combination (say: DDJJSHHIEM) they all have the value of zero. Why? What am I doing wrong?................Thanks