Spelling Alphabet

The spelling alphabet is a tool used by the military, police, and other professionals. It helps them to sound cool when they spell names. You’ve probably attempted to spell that way yourself, even if you didn’t know any official spelling alphabet. Lots of people say, “N as in Nancy.” That’s how the spelling alphabet works.

By the way, N is November, not Nancy.

Your task this month is to concoct code that accepts a single word as input and then uses the NATO phonetic alphabet to spell out that word. For example:

Type a word: program
Papa Romeo Oscar Golf Romeo Alfa Mike

The NATO phonetic alphabet spelling of the word program is shown above. The full alphabet consists of the following strings:

        "Alfa", "Bravo", "Charlie", "Delta", "Echo",
        "Foxtrot", "Golf", "Hotel", "India", "Juliett",
        "Kilo", "Lima", "Mike", "November", "Oscar",
        "Papa", "Quebec", "Romeo", "Sierra", "Tango",
        "Uniform", "Victor", "Whiskey", "Xray",
        "Yankee", "Zulu"

That’s all the help I’m going to give you. Even though I formatted that text as it should go into an array, I’m not going to give you the array format. Nope, it’s all up to you this time.

Multiple solutions exist for this problem, but you need to craft only one. As long as a single word is accepted as input, processed, and the spelling words are output properly, you pass.

Please try this Exercise on your own before you sneak a peek and view my solution.

Leave a Reply