Skip to main content
Logo image

Section 22.3 Linear Search Practice

Activity 22.1.

You are conducting a linguistic study and are interested in finding words that contain the letter ’t’ or ’T’ in the first half of the word (including the middle letter if there is one). Specifically, if the first half of the word does contain a ’t’ or a ’T’, your program’s output should be a 1, if the first half does not contain the letter ’t’ or ’T’, but the second half does, then your program should output a 2. Otherwise (if there is no ’t’ or ’T’ in the word at all), your program’s output should be -1. You may assume that the word entered does not have more than 50 letters.
Here are some examples:
Input: apple
Output: -1
Input: raincoat
Output: 2
Input: enter
Output: 1
Input: Taylor
Output: 1

admin.....open in new window

When you are done, please paste your code into the code submission box below: