Question

In: Computer Science

writte application ask 5 word ( input) and show all of them and then show them...

writte application ask 5 word ( input)
and show all of them and then show them in order from greatest to least in word lenght.

write this word for example:
watermelon , app, oranges , grap ، cucumber

show this on input ( for example:
watermelon , cucumber , oranges, grap, app

please send it with html code and java-script thanks ?

Solutions

Expert Solution

CODE IN JAVA:

import java.util.Scanner;
class WordDemo {

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       Scanner sc = new Scanner(System.in);
       String arr[] = new String[5];
       System.out.println("Enter 5 words:");
       for(int i=0;i<5;i++) {
           arr[i] = sc.nextLine();
       }
       //arranging the words from high length to low length using bubble sort
       for(int i=0;i<5;i++) {
           for(int j=0;j<4;j++) {
               if(arr[j].length()<arr[j+1].length()) {
                   String temp = arr[j];
                   arr[j] = arr[j+1];
                   arr[j+1] = temp ;
               }
           }
       }
       System.out.println("Now the words in the order is:");
       for(String str:arr)
           System.out.print(str+" ");
   }

}
OUTPUT:


Related Solutions

Write a Python program that will ask the user to input a word, will return the...
Write a Python program that will ask the user to input a word, will return the first letter of the input word, and ask the user to put another word, and so on, in the form of a loop. If the user chooses to stop, he or she should input the integer "0" for the loop to stop.
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
Write in javaScript: User input 5 words in one input, and print out the longest word.
Write in javaScript: User input 5 words in one input, and print out the longest word.
Write a program that echoes the input one word per line. Remove all punctuation and all...
Write a program that echoes the input one word per line. Remove all punctuation and all blank lines. Code must be written in C. Not c++ or c#. Input: Use the following Ogden Nash poem to test your program. The Parsnip The parsnip, children, I repeat, Is simply an anemic beet. Some people call the parsnip edible; Myself, I find this claim incredible Note: There are multiple blank lines before and after the title. There may be multiple blank spaces...
C programing. Ask user to enter a word on sting and print all possible combinations. (please...
C programing. Ask user to enter a word on sting and print all possible combinations. (please don't use printer) Using recursion. example ask user to input user: "ABC" output: ABC ACB BAC BCA CAB CBA
For questions that ask you to conduct an appropriate hypothesis test, please show all of the...
For questions that ask you to conduct an appropriate hypothesis test, please show all of the following: 1) A statement of the null and alternative hypotheses in words or symbols 2) The calculation of an appropriate test statistic (show your work) For test statistics involving the t-distribution: round to 3 decimal places. For test statistics involving the Normal distribution: round to 2 decimal places. 3) Calculation of the p-value or critical value, as appropriate (show your work) 4) Conclusion: do...
Create a small program that contains the following. ask the user to input their name ask...
Create a small program that contains the following. ask the user to input their name ask the user to input three numbers check if their first number is between their second and third numbers
Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask...
Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask the player to find each of a given set of words in a square table filled with single letters. A word can read horizontally (left or right), vertically (up or down), or along a 45 degree diagonal (in any of the four directions) formed by consecutively adjacent cells of the table; it may wrap around the table’s boundaries, but it must read in the...
Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask...
Word Find A popular diversion in the United States, “word find” (or “word search”) puzzles ask the player to find each of a given set of words in a square table filled with single letters. A word can read horizontally (left or right), vertically (up or down), or along a 45 degree diagonal (in any of the four directions) formed by consecutively adjacent cells of the table; it may wrap around the table’s boundaries, but it must read in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT