Working with Accounts

Report a typo

We have the Account data class with the initial amount, the result, and the status.

A new account has an amount of 50.

You have to write the calculateOperation function to calculate the final result value after applying CTE (integer value) and INC (integer value) to the amount parameter and change the status of the account to "END".

To obtain the value of the result, you must encode: amount * INC * CTE.

Sample Input 1:

6 3

Sample Output 1:

Account(id=1, amount=50, result=900, status=END)
Write a program in Kotlin
/* Do not change code below */
data class Account(
val id: Int = 1,
val amount: Int = 0,
val result: Int = 0,
val status: String = "START"
)

fun calculateOperation(
init: Account,
func: Account.() -> Account
): Account {
val account = init.copy(amount = 50)
return account.func()
}

/* Do not change code below */
fun main() {
val (INC, CTE) = readLine()!!.split(' ').map { it.toInt() }

val res = calculateOperation(Account()) {
// write your code here

}
println(res)
}
___

Create a free account to access the full topic