Middle Character

One of my favourites.  Write a program that tests the length of a string.  If the String is even it will output ‘even’.  If the string is odd it will output ‘odd’.

You will need to use an IF statement and find the length of the string using the String.length() method.

 Note:  The modulus of the string’s length e.g. length % 2 will return either 0 or 1 which you can use to determine odd or even

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.