I tried splitting up the words in the line and checking if they had periods, but I got an error:
falls.falls.falls.Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
at Alpha.main(Alpha.java:10)
Code:
import java.io.*;
import java.util.*;
public class Alpha
{
public static void main(String[] args)
{
String phrase = "the moon falls. the flowers grew.";
String beta = "";
String[] array = phrase.split(" ");
for (int i = 0; i < array.length; i++)
{
if (array[i].endsWith("."))
{
array[i + 1] = array[i + 1].substring(0, 1).toUpperCase() + array[i + 1].substring(1);
beta = beta + array[i];
}
System.out.print(beta);
}
}
}
(Also I don't think that's how I would call another word of an array, any suggestions on how I can fix that?)