Alright, here's my code...
import java.util.Scanner;
public class Letter
{
public static void main(String[] args)
{
//needed for scanner class
Scanner kb = new Scanner(System.in);
int charCount = 0;
// get users string
System.out.println("Please enter a string: ");
String userString = kb.nextLine();
// get users character
System.out.println("Please enter a character: ");
String userChar = kb.nextLine();
// tell the user what the program does
System.out.println("****This program will return how many times" +
" the character you entered showed up in" +
" the string you entered.****");
for(int i= 0;i<userString.length();i++)
{
if (userString.charAt(i) == userChar)
{
charCount++;
}
}
System.out.println("The specified character '" + userChar +
"' is inside the string '" + userString +
"'" + charCount + "' times.);
}
You can probably already see my error, but i'm getting incomparable types, obviously a string and a char. Any way to fix this?