Once again, I can get part of my code to work, but not all. When the user inputs more than one sentence (ending with either a period, question mark or exclamation point), each sentence should be capitalized accordingly. However, it only works with the first sentence to work. Does anyone have any suggestions on how to correct this? Thx in advance.
import javax.swing.JOptionPane;
public class sentenceStructure
{
public static void main(String[] args)
{
//Get user input
String s = JOptionPane.showInputDialog(null, "Enter more than one sentence.");
String[] sarray = s.split("'.','?','!'");
for (String begin: sarray)
{
String capitalize = begin.substring(0, 1).toUpperCase() +
begin.substring(1, begin.length() - 1);
//Show input capitalized
JOptionPane.showMessageDialog(null, capitalize);
}
System.exit(0);
}
}