Java "string index out of bounds"
<p>The program below is supposed to find the average letter in a string. Ex: "abc" the average is "b". When I run the program I get the error message below. Thanks for your help!<br>
PROGRAM:   </p>

<pre><code>import java.util.*;
public class AvLetter{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("enter a phrase");
String s = scan.nextLine();
s = s.toLowerCase();
int letterCount = 0; int sum = 0; char c;

for(int pos= 0; pos&lt; s.length(); pos++){ 
  c=s.charAt(pos);
  if  (Character.isLetter(c)) {
  sum = sum + (int)s.charAt(c);
  letterCount++;
  System.out.println((char)(sum/letterCount));
  }
}
}
}
</code></pre>

<p>ERROR MESSAGE:  </p>

<pre><code>java.lang.StringIndexOutOfBoundsException: String index out of range: 97
    at java.lang.String.charAt(String.java:686)
    at AvLetter.main(AvLetter.java:14)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
</code></pre>
