Text statistics

Report a typo

Modify the program below to output the statistics of the input text line: the number of characters, unique characters, and words.

Sample Input 1:

a b c

Sample Output 1:

characters: 5
unique characters: 4
words: 3
Write a program in Scala 3
object TextReportPrinter extends App {
val textLine = scala.io.StdIn.readLine()
println {
s"""characters: ???
|unique characters: ${textLine.toSet???}
|words: ${if (???isEmpty) ??? else ???split("\\s")???}
|""".stripMargin
}
}
___

Create a free account to access the full topic