Find the middle initial in spite of any number of excess blank spaces.
// loop past all the spaces to find the first letter
int i=0;
while(i<str.length()&&str.charAt(i)==' ')i++; // i is the location of the first letter of first name
int j=i;
//look past all the non-space characters to find the next blank space //j is the first blank space after first name
int k=j;
// loop past all the spaces to find the next letter // k is the first letter of middle name
int m=k;
//look past all the non-space characters to find the next blank space// m is the first blank space after second name
int n=m;
// loop past all the spaces to find the next letter // n is the location of the first letter of last name
//if you ended up past the end of the string, there is no last name.
//if there is a last name, then there is a middle initial, otherwise, there isn't
if(n<s.length())return(s.substring(k,k+1));
else return("none");