data class Line( val item: String, val cents: Int, ) val order = listOf( Line("coffee", 2400), Line("pastry", 1800), Line("tip", 800), ) fun Line.row(): String = item.padEnd(10) + "$cents".padStart(6) fun main() { val sum = order.sumOf { it.cents } val lines = order + Line("total", sum) lines.forEach { println(it.row()) } }