CSci 150: Foundations of computer science I
Home Syllabus Assignments Tests

Practice 3: Name game

Posted: Wednesday, September 16.

Write a program that plays the Name Game, as described by Shirley Ellis in her 1965 hit song of that name. In it, we take a person's name X (say, Lincoln), remove the first letter to arrive at Y (such as incoln), and then sing:

X, X, bo-bY,
Banana-fana fo-fY
Fee-fi-mo-mY
X!

For example, given the name Lincoln, one would sing:

Lincoln, Lincoln, bo-bincoln,
Banana-fana fo-fincoln
Fee-fi-mo-mincoln
Lincoln!

However, if the name begins with the same letter as the letter preceding the Y, then that letter is not sung. For example, for the name Mary, we would sing the Fee line as Fee-fi-mo-ary (rather than Fee-fi-mo-mary) but the Banana line would still end fo-fary.

Here is an example run of your program, where the user enters Gwendolyn

What is your name? Gwendolyn
Gwendolyn, Gwendolyn, bo-bwendolyn,
Banana-fana fo-fwendolyn
Fee-fi-mo-mwendolyn
Gwendolyn!

You do not need to worry about complexities such as names that start with a vowel such as Adam or Eliza (where the rule is that Y is taken to be the whole name) or names that start with multiple combined consonants such as Shirley or Chuck (where the rule is that Y excludes the consonant combination).