Ask Question
25 April, 04:30

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. 25 April, 04:44
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers