In this mini project, we'll bring together the Kotlin basics to build a simple course enrollment summary. You'll get hands-on practice using data classes, lists, functions, filter, map, and string templates all in one place. It's similar to the idea of processing a course list, an enrolled student list, or an active user list in a real app.
kotlin
data class Course(val title: String, val price: Int, val enrolled: Boolean)
fun calculateTotal(courses: List<Course>): Int {
return courses
.filter { it.enrolled }
.map { it.price }
.sum()
}
fun main() {
val courses = listOf(
Course("Kotlin Basics", 30000, true),
Course("Android UI", 45000, false),
Course("Backend API", 50000, true)
)
val enrolledCourses = courses.filter { it.enrolled }
val titles = enrolledCourses.map { it.title }
val total = calculateTotal(courses)
println("Enrolled courses: $titles")
println("Total price: $total MMK")
}You should see
Enrolled courses: [Kotlin Basics, Backend API] Total price: 80000 MMKSummary
This mini project pulls together the Kotlin fundamentals into a real-world data processing flow.
What's Next
Once you're done with this stage, you can move on to Kotlin coroutines, Android Jetpack Compose, and Spring Boot with Kotlin.