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

Well, you do not call the printCapitalized() method anywhere in your main method, so it's not going to do anything until you call it.

jup, nothing wrong with the code, and it's doing all you've told it to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.