I´m trying to program for so long now and it won´t work. I need a program, which does following:
User Input: I´m looking for some food. I love food. System Print: Food some for looking I´m. Food love I.
Reverse the words, UpperWord the first word, start with next sentence a keep the "." at it´s place.
package finaledition;
public class finaledition {
public static void main(String[] args) {
StringBuilder outputString= new StringBuilder();
String satz;
String wort;
System.out.print("Bitte geben Sie einen String ein: ");
String text = Input.readString();
while (text.indexOf('.') > 0) {
satz = text.substring(0, text.indexOf('.'));
text = text.substring(text.indexOf('.') + 1);
while (satz.lastIndexOf(' ') > 0) {
wort = satz.substring(satz.lastIndexOf(' ') + 1);
outputString.append(wort);
satz = satz.substring(0, satz.lastIndexOf(' '));
}
System.out.print(outputString);
}
}
}
The actual result is:
foodsomeforlookingfoodsomeforlookingfoodlove