Final Project: Student Management App Foundation
Combine Kotlin classes, lists, functions, properties and decision-making to create the foundation of a student management application.
Kotlin Code
Study the example and understand each part.
data class Student(
val name: String,
val age: Int,
val marks: Double
)
fun grade(marks: Double): String {
return when {
marks >= 70 -> "A"
marks >= 60 -> "B"
marks >= 50 -> "C"
else -> "D"
}
}
fun main() {
val students = listOf(
Student(
"Brian",
18,
78.0
),
Student(
"Mary",
19,
85.0
),
Student(
"John",
18,
62.0
)
)
students.forEach { student ->
println(
"Name: ${student.name}"
)
println(
"Age: ${student.age}"
)
println(
"Marks: ${student.marks}"
)
println(
"Grade: ${grade(student.marks)}"
)
println("----------------")
}
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
A real student management application can build on this foundation by adding Android screens, databases, authentication, search, reporting and API integration.
Expected Output / Result
Name: Brian Age: 18 Marks: 78.0 Grade: A ---------------- Name: Mary Age: 19 Marks: 85.0 Grade: A ---------------- Name: John Age: 18 Marks: 62.0 Grade: B ----------------
Finished this lesson?
Mark it complete to update your course progress.