Middle Character

The Task

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
About CDB 361 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


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