Here is the code:
public class ConsonantCounter implements Bag<String>
{
private Bag<String> letters;
private Bag<String> vowels;
private Bag<String> consonants;
public ConsonantCounter()
{
letters = new Bag<String>();
vowels = new Bag<String>();
consonants = new Bag<String>();
}
public Bag<String> getConsonants(String str)
{
String upStrings = str.trim().toUpperCase();
vowels.add("A");
vowels.add("E");
vowels.add("I");
vowels.add("O");
vowels.add("U");
for(int index=0; index < str.length(); index++)
{
String characterString = upStrings.substring(index, index + 1);
Character character = characterString.charAt(0);
if (Character.isLetter(character))
{
String newchar = character.toString();
letters.add(newchar);
}
}
for(int index2 = 0; index2< letters.getCurrentSize(); index2++)
{
}
}
public String toUpperCase()
{
}
/**
* getFrequency returns the frequency of the given consonant
*
* @param true
* @return frequency of a consonant in the string
*/
public int getFrequency(String consonant)
{
}
}

New Topic/Question
Reply


MultiQuote



|