PPB A - Tugas 6

 

Nama: Schaquille Devlin Aristano

NRP: 5025211211

Kelas: PPB A

Membuat program konversi mata uang

Kode:

 fun convert(input: Double, currency: String): Double
{
    when(currency)
    {
        "RUB" -> return(input * 0.004873)
        "CNY" -> return(input * 0.000433)
        "KPW" -> return(input * 0.050000)
        "CUP" -> return(input * 0.001527)
        "PKR" -> return(input * 0.020000)
        "AFN" -> return(input * 0.004272)
        "MYR" -> return(input * 0.000261)
        "THB" -> return(input * 0.001978)
        "LAK" -> return(input * 1.280000)
        "PHP" -> return(input * 0.003362)
        else -> {
            return input
        }
    }
}

fun curr_symbol(currency: String): String
{
    when(currency)
    {
        "RUB" -> return "₽"
        "CNY" -> return "¥"
        "KPW" -> return "₩"
        "CUP" -> return "₱"
        "PKR" -> return "₨"
        "AFN" -> return "؋"
        "MYR" -> return "RM"
        "THB" -> return "฿"
        "LAK" -> return "₭"
        "PHP" -> return "₱"
        else -> {
            return "??"
        }
    }
}

fun main()
{
    val input: Double = 10_000.00
    val currency: String = "RUB"
    println("Rp " + input + " = " + curr_symbol(currency) + " " + convert(input, currency))
}

 Screenshot:


 

 

Comments

Popular posts from this blog

PPB 1