data class Point(val x: Double, val y: Double)
data class Rectangle(val topLeft: Point, val bottomRight: Point)
fun getCenter(rect: Rectangle): Point {
val centerX = (rect.topLeft.x + rect.bottomRight.x) / 2.0
val centerY = (rect.topLeft.y + rect.bottomRight.y) / 2.0
return Point(centerX, centerY)
}
fun main() {
val rect = Rectangle(Point(10.0, 20.0), Point(110.0, 70.0))
val center = getCenter(rect)
println("Center of the rectangle: (%.2f, %.2f)".format(center.x, center.y))
}
/*
run:
Center of the rectangle: (60.00, 45.00)
*/