Manipulating with numbers

Report a typo

Now you are working with a sequence of numbers. Your job is to multiply an odd number by 2 and to add 10 to an even number.
You have two methods that help you perform these operations:

fun multiplyByTwo(number: Int): Int {
    return number * 2
}

fun addTen(number: Int): Int {
    return number + 10
}

Write a program that reads numbers and performs certain actions depending on the parity of the number.
You are given the sequence of numbers itself separated by a space.

Sample Input 1:

1 2

Sample Output 1:

2 12
Write a program in Kotlin
fun multiplyByTwo(number: Int): Int {
return number * 2
}

fun addTen(number: Int): Int {
return number + 10
}

fun changeNumber(changeFunction: (Int) -> Int, number: Int) {
val newNumber = changeFunction(number)
print("$newNumber ")
}

fun main() {
val numbers = readLine()!!.split(' ').map { it.toInt() }.toList()
var numberFun: (Int) -> Int
for (number in numbers) {
// write your code here

changeNumber(numberFun, number)
}
}
___

Create a free account to access the full topic