I need to count the number of letters in a string, disregarding case. It needs to use these two methods. What's wrong?
Code:
import java.util.Scanner;
public class CountLetters
{
public static void main(String[] args)
{
Scanner input;
input = new java.util.Scanner(System.in);
String s;
int count = 0;
System.out.print( "Enter a string: " );
s = input.nextLine();
count = s.length();
System.out.println("The number of letters in the string is " +count+".");
}
public static int count (String s)
{
int count = 0;
count = s.length();
for(int i = 0; i < s.length(); i++) {
if(s.charAt(i) == 'i')
{
count++;
}
}}}
Comment