The code is supposed to capitalize the first letter of the word typed and reverse the sentence.
I believe i messed up here "String firstchar = sentence.substring (lString+1,lSpace+2).toUpperCase();"
I'm totally new to java and have no clue what could have went wrong :'(
import java.util.Scanner; public class reverseSentence { public static void main ( String [] args) { String sentence, piece1,piece2; int lSpace; Scanner input = new Scanner (System.in); System.out.println ("Enter a sentence no punctuation"); sentence = input.nextLine(); lSpace = sentence.indexOf(""); piece1 = sentence.substring(0,lSpace); piece2 = sentence.substring(lspace+2); String firstchar = sentence.substring (lString+1,lSpace+2).toUpperCase(); system.out.println(firstChar + piece2 + " " + piece1); } }