Objective

Extract out individual words from a hyphenated word.

Difficulty

Very easy

Description

Ask the user to input a hyphenated word by the following input prompt message:

Enter a hyphenated word:

Once the word is given, extract out the constituent words from it, and print each on a new line.

Shown below is an example:

Enter a hyphenated word: awe-inspiring

awe
inspiring

If the input word is not hyphenated i.e. there is not a hyphen (-) in it, print 'Invalid input!', and keep asking the user to enter a hyphenated string, as shown above, until the correct input is received.

Shown below is a demonstration:

Enter a hyphenated word: amazing
Invalid input!

Enter a hyphenated word: programming
Invalid input!

Enter a hyphenated word: strongly-typed

strongly
typed

Note the blank lines over here.

If the input value is invalid, print 'Invalid input!' and then leave a blank line before asking the user to input again. If the input value is valid, leave a blank line before printing out all the constituent words in the hyphenated word.

Hints