import java.util.*;
public class Exercise60 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input a Sentence: ");
String line = in.nextLine();
String[] words = line.split("[ ]+");
System.out.println("Penultimate word: "+words[words.length - 2]);
}
}
Sample Output:
Input a Sentence: The quick brown fox jumps over the lazy dog.
Penultimate word: lazy
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer