Question

Write an application in java that accepts any number of String values from a user until...

Write an application in java that accepts any number of String values from a user until they enter zzz or have entered 15 strings, and display them in ascending order.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;

public class Strings {


    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        int count = 0;
        ArrayList<String> userStrings = new ArrayList<>();

        while (count < 15) {
            System.out.print("Enter string value: ");
            String input = scanner.nextLine();
            if (input.equalsIgnoreCase("zzz")) {
                break;
            } else {
                userStrings.add(input);
            }
            count+=1;
        }
        Collections.sort(userStrings);
        for (String value : userStrings) {
            System.out.println(value);
        }

    }


}
Add a comment
Know the answer?
Add Answer to:
Write an application in java that accepts any number of String values from a user until...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that accepts numbers entered by the user until the user enters a zero....

    Write a program that accepts numbers entered by the user until the user enters a zero. The program then must display the largest value that is smaller than zero. This should be java program

  • NOTE: Use JOptionPane NOT Scanner Please Write an application that allows a user to enter the...

    NOTE: Use JOptionPane NOT Scanner Please Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user...

  • Write a java program that accepts a string from the user. List all characters in the...

    Write a java program that accepts a string from the user. List all characters in the string from lowest ASCII value to highest and output the number of occurrences for each of those characters.

  • Need Java help: 1. Create a Java program that accepts input String input from a user...

    Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.

  • In the first task, you will write a Java program that accepts a string of the...

    In the first task, you will write a Java program that accepts a string of the format specified next and calculate the answer based on the user input. The input string should be of the format dddxxdddxx*, where d represents a digit and x represents any character and asterisk at the end represents that the string can have any number of characters at the end. 1. Prompt the user to enter a string with the specific format (dddxxdddxx*) 2. Read...

  • PYTHON PROGRAM Write an application that accepts a sentence as input from the user and displays...

    PYTHON PROGRAM Write an application that accepts a sentence as input from the user and displays all of the words in the sentence that have an odd number of letters in them

  • Write a Java program that reads a series of strings from a user until STOP is...

    Write a Java program that reads a series of strings from a user until STOP is entered. Each input consists of information about one student at the ABC Professional School. The input consists of the student’s last name (the first 15 characters with extra blanks on the right if the name is not 15 characters long), the student’s number (the next 4 characters, all digits, a number between 1000 and 5999), and the student’s program of study (one character, either...

  • Write a java program that keeps asking the user to enter a number until the user...

    Write a java program that keeps asking the user to enter a number until the user quits and prints how many even and how many odd numbers entered by the user. The loop terminates if the user enters -1 (it indicates that there will be no more number entering by the user). In other words, as long as the user doesn’t enter -1, the loop will be executed. Please add comments to the program to understand/ explain the code.

  • Design and implement a Java program (name it PasswordTest) that accepts a string from the user...

    Design and implement a Java program (name it PasswordTest) that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict A good password will be at least 8 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order...

  • Allow a user to enter any number of double values up to 15. The user should...

    Allow a user to enter any number of double values up to 15. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. DistanceFromAverage.java

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT