Jump to content

The Name Game: Difference between revisions

Line 640:
</pre>
 
=={{header|Scala}}==
<lang Scala>object NameGame extends App {
private def printVerse(name: String): Unit = {
val x = name.toLowerCase.capitalize
 
val y = if ("AEIOU" contains x.head) x.toLowerCase else x.tail
 
val (b, f, m) = x.head match {
case 'B' => (y, "f" + y, "m" + y)
case 'F' => ("b" + y, y, "m" + y)
case 'M' => ("b" + y, "f" + y, y)
case _ => ("b" + y, "f" + y, "m" + y)
}
 
printf("%s, %s, bo-%s\n", x, x, b)
printf("Banana-fana fo-%s\n", f)
println(s"Fee-fi-mo-$m")
println(s"$x!\n")
}
 
Stream("gAry", "earl", "Billy", "Felix", "Mary", "Steve").foreach(printVerse)
}</lang>
 
See it running in your browser by [https://scastie.scala-lang.org/UilFJ0zFSJu4Qk2xaw2r4A Scastie (JVM)].
=={{header|VBA}}==
<lang vb>Option Explicit
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.