Question

In Javascript: Write a function named "categorize" that takes a string as a parameter and returns...

In Javascript: Write a function named "categorize" that takes a string as a parameter and returns "short" if the input has less than 6 characters, "medium" if the input has greater than or equal to 6 but less than 7, and returns "long" if the input has greater than or equal to 7 characters. Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Program

{

   public static void main(String args[])

   {

      string s;

      int len;

      scanner sc = new Scanner(System.in);     

      system.out.print("Enter The String : ");

      s = scan.nextLine();

      l = s.length();

      if(l<6)

         system.out.print(“short”);

     else if(l>=6 && l<7 )

         system.out.print(“medium”);

     else

        system.out.print(“long”);

   }

}

Add a comment
Know the answer?
Add Answer to:
In Javascript: Write a function named "categorize" that takes a string as a parameter and returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT