Ask Question
29 June, 04:00

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.

+1
Answers (1)
  1. 29 June, 05:45
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers