I need help making a word frequency counter that also gives percentages of the amount of time the character occured. I am having trouble compiling my program. Thanks.
import java.util.*;
public class GoodLetterCounter
{
public static void main(String[] args)
{
System.out.println("\n-This program will show how many times" +
" the character showed up in the string.-" );
System.out.println("");
Scanner keyboard = new Scanner(System.in);
int charCount = 0;
System.out.print("Please enter a string: ");
String userString = keyboard.nextLine();
System.out.print("Please enter a character that was in the string: ");
char userChar = keyboard.nextLine().charAt(0);
for(int i= 0;i<userString.length();i++)
{
if (userString.charAt(i) == userChar)
{
charCount++;
}
}
System.out.println("\nThe character " +"\"" + userChar +
"\" appeared " + charCount+ " times." );
System.out.println("the frequency was" + charCount/userString + "%");
}
}