Count words, characters, and letters in text.

Counting Words

WordCount.scala
object Main {
  def main(args: Array[String]): Unit = {
    val text = 
    val words = text.split(" ").toList
    val chars = text.length
    val letters = text.replace(" ", "").length

    println("words=" + words.length)
    println("chars=" + chars)
    println("letters=" + letters)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val text = 
    val words = text.split(" ").toList
    val chars = text.length
    val letters = text.replace(" ", "").length

    println("words=" + words.length)
    println("chars=" + chars)
    println("letters=" + letters)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val text = 
    val words = text.split(" ").toList
    val chars = text.length
    val letters = text.replace(" ", "").length

    println("words=" + words.length)
    println("chars=" + chars)
    println("letters=" + letters)
  }
}
word-count Splitting on spaces counts words, `length` counts characters, and removing the spaces first counts only the letters.