Decoding a specific user command

Report a typo

You've received a user command that always starts with the word 'RUN' followed by a string that may vary. Create a program that decodes this command and prints 'true' if the command is 'RUN silent' and 'false' in any other case. The input will be a single line with the command and the output should be a single boolean value.

Sample Input 1:

RUN silent

Sample Output 1:

true

Sample Input 2:

RUN loud

Sample Output 2:

false
Write a program in Kotlin
// imports here
import java.util.*

// The "Scanner" class is used to get user input for primitive types like int, double, etc.
val scanner = Scanner(System.`in`)

/**
* Read the line provided by the user
*/
fun readInput(): String {
return scanner.nextLine()
}

/**
* Evaluate the command 'RUN silent' and return 'true' or 'false' accordingly.
* Please write your boolean logic here to solve the problem.
*/
fun evaluateCommand(input: String): Boolean {
// Write your code here!
throw NotImplementedError("Not implemented yet!")
}

/**
* The main function, answer to the problem must be printed from this function
*/
fun main() {
val command = readInput()
val result = evaluateCommand(command)
println(result)
}
___

Create a free account to access the full topic