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.
Boolean type and operations. True and false
Decoding a specific user command
Report a typo
Sample Input 1:
RUN silentSample Output 1:
trueSample Input 2:
RUN loudSample Output 2:
falseWrite 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)
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
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.