14) Write a complete Java class that uses the console window to prompt the user for a sentence to parse. Use the StringTokenizer class to echo the tokens back to the console.

What will be an ideal response?


```
import java.util.Scanner;
import java.util.StringTokenizer;

public class Parser
{
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a sentence and I'll display each word you entered: ");
String sentence = keyboard.nextLine();
//Parse the string into tokens and echo back to the user
StringTokenizer tk = new StringTokenizer(sentence, " ");
System.out.println("Here are the tokens: ");
while(tk.hasMoreTokens())
{
System.out.println(tk.nextToken());
}
}
}
```

Computer Science & Information Technology

You might also like to view...

Panels are _________________________ when they display only an icon.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The home page features a panel on the upper-right side that displays the most recent activity surrounding your pins and boards

Indicate whether the statement is true or false

Computer Science & Information Technology

When the border of a shape in a SmartArt graphic appears as a series of dashes (----- ), the ________ can be edited

Fill in the blank(s) with correct word

Computer Science & Information Technology

A 64-bit Windows 10 installation requires 20GB or more of free hard drive space

Indicate whether the statement is true or false

Computer Science & Information Technology