Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.0 kB
0
Indexable
Never
fun main (args:Array<String>) {
    var count = 0
    var carcount = 0
    for (i in 1..2)
        if (count <= 0) {
            println("enter the number of items: ")
            carcount = readLine()!!.toInt()
        }
        else
            i++

    var cartype= arrayListOf<String>()
    val cartype11= Regex("(^[a-zA-Z])")
    var carmodle= arrayListOf<String>()
    var caryear= arrayListOf<Int>()
    val caryear11 = Regex("(^[0-9{4}])")
    var carprice= arrayListOf<Double>()
    var carrange= arrayListOf<Int>()
    val carrange11 = Regex("(^[0-9])")
    var carnum= hashMapOf<Int,String>()

    for (i in 1 .. carcount) {
        println("Please enter car type. ")
        cartype[i]= readLine()!!
        for ( i in 1 .. 2) {
            if(cartype11.matches() {
                    println("thank you")
                    i++

            else {
                println("please enter correct car type")
            }
        }}}

        println("Please enter car modle. ")
        carmodle[i]= readLine()!!
        println("Please enter car year. ")
        caryear[i]= readLine()!!.toInt()
    for (i in 1 .. 2) {
    if(caryear11.matches(caryear.toString())){
        println("thank you")
        i++
    }
    else {
        println("please enter correct car year")
    }
}
    for (i in 1 .. count) {
        println("Please enter car price. ")
        carprice[i] = readLine()!!.toDouble()
        i++
    }
    for (z in 1 .. count) {
        println("Please enter car range. ")
        carrange[z] = readLine()!!.toInt()
        for (i in 1..2) {
            if (carrange11.matches(carrange.toString())) {
                println("thank you")
                i++
            } else {
                println("please enter correct car range")
            }
        }
        z++
    }
        println("Please enter the car num. ")
        carnum.run { (get(readLine()!!.toInt()).toString()) }

    }