In Kotlin, write a code snippet that takes a single integer as input and creates a read-only (val) variable that equals twice of the input. The program should then print the value of that variable.
Constants and val variables
Creating and printing a double value of an integer input
Report a typo
Sample Input 1:
2Sample Output 1:
4Sample Input 2:
7Sample Output 2:
14Write a program in Kotlin
// Start of the program
fun main(args: Array<String>) {
/* The program reads an integer from the input.
* Input a single integer.
*/
val x = readLine()!!.toInt()
// Create a read-only (val) variable that equals twice of the input
// Your code here
// Print the value of the variable
// Your code here
}
// End of the program
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.