Ask Question
31 January, 09:26

Write a program that reads a word and prints whether it is short (fewer than 5 letters). it is long (at least 10 letters). it ends with the letter y.

+3
Answers (1)
  1. 31 January, 12:51
    0
    import java. util. Scanner;

    public class WordProperties

    {

    public static void main (String[] args)

    {

    Scanner in = new Scanner (System. in);

    System. out. print ("Enter a word: ");

    String word = in. next ();

    //check if it is short (fewer than 5 letters).

    if (word. length () <5)

    {

    System. out. println (word + " is short");

    }

    //check if it is long (at least 10 letters).

    if (word. length () >=10)

    {

    System. out. println (word + " is long");

    }

    //check if it ends with the letter y

    if (word. charAt (word. length () - 1) = ='y')

    {

    System. out. println (word + " ends in a y");

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that reads a word and prints whether it is short (fewer than 5 letters). it is long (at least 10 letters). it ends with the ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers