The Name Game: Difference between revisions

Content added Content deleted
(Added Go)
Line 247: Line 247:
Fee-fi-mo-mteve
Fee-fi-mo-mteve
Steve!
Steve!
</pre>

=={{header|Go}}==
{{trans|Kotlin}}
<lang go>package main

import (
"fmt"
"strings"
)

func printVerse(name string) {
x := strings.Title(strings.ToLower(name))
y := x[1:]
if strings.Contains("AEIOU", x[:1]) {
y = strings.ToLower(x)
}
b := "b" + y
f := "f" + y
m := "m" + y
switch x[0] {
case 'B':
b = y
case 'F':
f = y
case 'M':
m = y
}
fmt.Printf("%s, %s, bo-%s\n", x, x, b)
fmt.Printf("Banana-fana fo-%s\n", f)
fmt.Printf("Fee-fi-mo-%s\n", m)
fmt.Printf("%s!\n\n", x)
}

func main() {
names := [6]string{"gARY", "Earl", "Billy", "Felix", "Mary", "SHIRley"}
for _, name := range names {
printVerse(name)
}
}</lang>

{{out}}
<pre>
Gary, Gary, bo-bary
Banana-fana fo-fary
Fee-fi-mo-mary
Gary!

Earl, Earl, bo-bearl
Banana-fana fo-fearl
Fee-fi-mo-mearl
Earl!

Billy, Billy, bo-illy
Banana-fana fo-filly
Fee-fi-mo-milly
Billy!

Felix, Felix, bo-belix
Banana-fana fo-elix
Fee-fi-mo-melix
Felix!

Mary, Mary, bo-bary
Banana-fana fo-fary
Fee-fi-mo-ary
Mary!

Shirley, Shirley, bo-bhirley
Banana-fana fo-fhirley
Fee-fi-mo-mhirley
Shirley!
</pre>
</pre>