Calculating the cube of a user-specified integer

Report a typo

Write a Kotlin program that takes an integer input from the user and then calculates the cube of that number. This calculation should be stored in a val variable and the program should print the cube of given number. Assume that the number is always a positive integer.

Sample Input 1:

4

Sample Output 1:

64

Sample Input 2:

2

Sample Output 2:

8
Write a program in Kotlin
import java.util.*

fun main(args: Array<String>) {
val scanner = Scanner(System.`in`)

// Get user input
val userInput = scanner.nextInt()

// Calculate the cube of userInput

// Print the result
}

Create a free account to access the full topic