Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Scala program to convert string to reverse case #5665

Merged
merged 2 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ConvertStringToReversecase.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
object ReverseCase {

def toReverseCase(str: String): String = {
str.map(c => {
if (c.isLower) c.toUpper else c.toLower
})
}

def main(args: Array[String]): Unit = {
val inputString = "hello world"
val reversedCase = toReverseCase(inputString)

println(s"Input String: $inputString")
println(s"Reverse Case: $reversedCase")
}
}