toString() modification

Report a typo

There is a program that reads three numbers (height, length, width) and prints all of them as fields of a data class, that is, Box. There is also an internal field which is size.

Modify the data class in order to print only the height, width, and size values.

Sample Input 1:

3 21 6

Sample Output 1:

Box(height=3, width=6, size=30)
Write a program in Kotlin
data class Box(val height: Int, val length: Int, val width: Int) {
var size: Int = height + length + width
}
___

Create a free account to access the full topic