middleCharacter 🌶️
Write a method that takes one String parameter, s, and returns the single character in the exact middle of s, as a one-character String. For example, middleCharacter("cat") should return "a". You may assume s always has an ODD number of characters (so there is always exactly one middle character), and at least one character.
Work out the middle index by hand for a couple of odd lengths first. For "cat" (length 3) the middle character is at index 1; for "abcde" (length 5) it is at index 2; for "racecar" (length 7) it is at index 3. What single calculation turns 3 into 1, 5 into 2, and 7 into 3?
Does int division throw away the remainder? Could that work in your favor here instead of against you?