So i did my code, he asks for the string then i put it, then he tells me what string i put in but for some reason i dont understand he doesnt show the capitalized first letter for each word coverted string.
Here is my code:
import java.io.*;
public class LerString {
public static void main(String[] args) {
boolean stop;
do {
System.out.println("Enter your string");
BufferedReader si = new BufferedReader(
new InputStreamReader(System.in));
String s = null;
try { s = si.readLine(); }
catch(IOException e) { System.out.println("error"); }
System.out.println("You Entered " +s);
stop = s.equals("stop it");
}
while(!stop);
}
static void printCapitalized(String s) {
char ch;
char prevCh;
prevCh = '.';
for ( int i=0 ; i < s.length(); i++ ) {
ch = s.charAt(i);
if ( Character.isLetter(ch) && ! Character.isLetter(prevCh) )
System.out.print( Character.toUpperCase(ch) );
else
System.out.print( Character.toLowerCase(ch) );
prevCh = ch;
}
System.out.println();
}
}
Any Ideas would be much appreciated
Cheers