Write a program in Kotlin that reads a string and returns the reversed version of that string. Your program should interactively ask the user for a single string and should display the reversed string as the output.
String basics
Reverse a user-input string
Report a typo
Sample Input 1:
HelloSample Output 1:
olleHSample Input 2:
KotlinSample Output 2:
niltoKWrite a program in Kotlin
import java.util.Scanner // Required for reading user input.
fun main(args: Array<String>) {
// Create a scanner object for reading user input.
val scanner = Scanner(System.`in`)
// Read a line of input from the user.
val inputString = scanner.nextLine()
// Call your function here to reverse the inputString.
// Print the reversed string.
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.