Question: Write a Java application with a mainf) method to find the shortest and longest words entered at the terminal by the user. All of your


Write a Java application with a mainf) method to find the shortest and longest words entered at the terminal by the user. All of your code can be in main). We are not running a graphic application. We are just creating a simple standalone application. NOTE: You may not use any form of data structures (i.e. Arrays, ArrayLists, Trees, Priority Queues, HasbMaps, HashBrowos, etc.) in your code for this program. You only need a few variables to keep track of the shortest and longest words. Use logic to determine if and how the variables are assigned. Your program should be able to handle any number of entries. Use a Scanner object to read user input from standard input (System.in) The basic framework to use a Scanner is // Construct a Scanner that produces strings scanned from standard input Scanner input - new Scanner (System.in); // While there is more input (user has not hit EOF // Read the next word entered by the user String iWord Sample Output: Enter a series of words (EOF to quit): hi hello Length of the shortest word: 2 -Number of words with shortest length : -- Shortest word: hi Length of the longest word: 5 Number of words with longest length: 1 -Longest word: hello Enter a series of words (EOF to quit): No words entered Enter a series of words (EOF to quit): dog cat Length of the shortest word: 3 -Number of words with shortest length : 2 First/last shortest words: dog cat Length of the longest word: 3 -Number of words with longest length: 2 -First/last longest words: dog cat
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
