Library contents

Kotlin uppercase

Convert a three-letter airport code to uppercase before comparing it with a timetable.

A simple example

uppercase

  1. Start with "ab"
  2. Do this Convert to uppercase
  3. Result "AB"
Both ASCII letters acquire their uppercase forms.
Lesson.kt
fun main() {
    val value = "ab"
    println(value.uppercase())
}
Output
AB

Syntax

Kotlin syntax
label.uppercase()
Run these examples in Kotlin

Save one example at a time as Lesson.kt. Use Kotlin 2.2 on JDK 21.

kotlinc Lesson.kt -include-runtime -d lesson.jar
java -jar lesson.jar

Standardize an airport code

A travel desk receives airport codes in mixed case from several forms. Convert the code to the required display case so it can be compared with the label on the boarding pass.

From the programval label = "maa"
ResultMAA
Lesson.kt

fun main() {
    val label = "maa"
    println(label.uppercase())
}
Output
MAA

The lowercase letters become MAA, the code displayed on the ticket.

Advertisements

Print an airport tag

A traveler types an airport abbreviation using a personal keyboard. The printed luggage tag must use the standard uppercase spelling so the code is easy to identify on the belt.

From the programval value = "maa"
ResultMAA
Lesson.kt
fun main() {
    val value = "maa"
    println(value.uppercase())
}
Output
MAA

All three ASCII letters become capitals.

Standardize a lab section

Two terminals can enter the same short label with different capitalization or padding. Normalize the incoming spelling before lookup so the stored identifiers can follow a consistent convention.

From the programval value = "bio-2"
ResultBIO-2
Lesson.kt
fun main() {
    val value = "bio-2"
    println(value.uppercase())
}
Output
BIO-2

The number and hyphen are unaffected.

What to watch for

Airport codes use ASCII. Names and other human text may need language-specific case handling.

Documentation for uppercase