/* CapitalsMap.kt Copyright (c) Kari Laitinen http://www.naturalprogramming.com 2020-10-30 File created. */ fun main() { // First we create a map (dictionary) in which countries and capitals // are stored as Key-Value pairs. Country name is the key. val countries_and_capitals = mapOf( "Finland" to "Helsinki", "Usa" to "Washington", "Denmark" to "Copenhagen", "Afghanistan" to "Kabul", "Russia" to "Moscow", "England" to "London", "Italy" to "Rome", "France" to "Paris", "Spain" to "Madrid", "Portugal" to "Lisbon", "Chile" to "Santiago", "Japan" to "Tokyo", "Sweden" to "Stockholm", "Norway" to "Oslo", "Pakistan" to "Islamabad", "Iceland" to "Reykjavik", "Hungary" to "Budapest", "Holland" to "Amsterdam", "Belgium" to "Brussels", "Austria" to "Vienna", "Israel" to "Jerusalem" ) print( "\n This program may know the capital of a country." + "\n Type in the name of some country: " ) val country_name = readLine()!!.toLowerCase().capitalize() if ( country_name in countries_and_capitals ) { val capital_name = countries_and_capitals[ country_name ] print( "\n The capital of " + country_name + " is " + capital_name + ".\n\n" ) } else { print( "\n Sorry, I do not know the capital of " + country_name + ".\n\n" ) } }