V
Vinsoft Lab
Learn • Build • Grow
Mobile Development Intermediate Paid

Kotlin Mobile Development

Learn Kotlin from the fundamentals to object-oriented programming, collections, null safety, functions and Android development foundations.

10 Weeks 24 Lessons Android Development Foundation
Your Progress 0%
LESSON 23

Mini Project: Grade Calculator

Build a small Kotlin program that calculates an average mark and determines a grade.

Kotlin Code

Study the example and understand each part.

KOTLIN
fun calculateGrade(
    average: Double
): String {

    return when {

        average >= 70 -> "A"

        average >= 60 -> "B"

        average >= 50 -> "C"

        else -> "D"

    }

}


fun main() {

    val mathematics = 80
    val science = 75
    val english = 85

    val average =
        (mathematics +
         science +
         english) / 3.0

    println("Average: $average")

    println(
        "Grade: ${calculateGrade(average)}"
    )

}

Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.

Key Concept

This project combines variables, functions, arithmetic and when expressions into one practical program.

Expected Output / Result

Average: 80.0
Grade: A

Finished this lesson?

Mark it complete to update your course progress.

Quick Knowledge Check

Test your Kotlin understanding.

Which keyword creates a read-only variable in Kotlin?

Vinsoft Lab Academy

Learn Kotlin. Build Android applications.

Build a strong Kotlin foundation and continue into practical Android application development.