Write a Kotlin program that calculates the square and the square root of a given integer. The input will be the integer to process. The output should be a string in the format 'Square: X, Square root: Y'.
Arithmetic operations
Calculate square and square root of a number
Report a typo
Sample Input 1:
5Sample Output 1:
Square: 25, Square root: 2.23606797749979Sample Input 2:
9Sample Output 2:
Square: 81, Square root: 3.0Write a program in Kotlin
// Importing required library
import kotlin.math.sqrt
fun main(args: Array<String>) {
// Reading the integer from user
val input = readLine()!!.toInt()
// Perform the arithmetic operations on 'input' here
// Prepare the output in required format and print it
val result =
println(result)
}
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.