Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in one of two lists: 1. one list for short Strings that are 10 characters or fewer. 2. and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String list to display, either $ for short or L for long and then output the correct list. For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings output The list is empty. Prompt the user continuously until a sentinel value, ZZZ, is entered to quit the program. An example of the program is shown below. Enter a string or ZZZ to quit >> Green Enter a string or ZZZ to quit >> Green eggs Enter a string or ZZZ to quit >> Green eggs and ham Enter a string or ZZZ to quit >> I do not like green eggs and ham Enter a string or ZZZ to quit >> ZZZ Do you want to see the list of short strings or the list of long strings? Please enter S or L or ZZZ to quit >> S Green Green eggs Do you want to see the list of short strings or the list of long strings? Please enter S or L or ZZZ to quit >> L Green eggs and ham I do not like green eggs and ham Do you want to see the list of short strings or the list of long strings? Please enter S or L or ZZZ to quit >> ZZZ 1 import java.util.*; 2 public class CategorizeStrings 3 { 9912 10} 11 public static void main (String[] args) { } // your code here // display()
JAVA:
Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in one of two lists:
- one list for short Strings that are 10 characters or fewer,
- and another list for long Strings that are 11 characters or more.
After data entry is complete, prompt the user to enter which type of String list to display, either S for short or L for long and then output the correct list.
For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings, output The list is empty. Prompt the user continuously until a sentinel value, ZZZ, is entered to quit the
An example of the program is shown below:
Enter a string or ZZZ to quit >> Green
Enter a string or ZZZ to quit >> Green eggs
Enter a string or ZZZ to quit >> Green eggs and ham
Enter a string or ZZZ to quit >> I do not like green eggs and ham
Enter a string or ZZZ to quit >> ZZZ
Do you want to see the list of short strings or the list of long strings?
Please enter S or L or ZZZ to quit >> S
Green
Green eggs
Do you want to see the list of short strings or the list of long strings?
Please enter S or L or ZZZ to quit >> L
Green eggs and ham
I do not like green eggs and ham
Do you want to see the list of short strings or the list of long strings?
Please enter S or L or ZZZ to quit >> ZZZ
Step by step
Solved in 3 steps with 2 images