Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.0 kB
5
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>(carcount){""}
    val cartype11= Regex("(^[a-zA-Z])")
    var carmodle= arrayListOf<String>(carcount){""}
    var caryear= arrayListOf<Int>(carcount){0000}
    val caryear11 = Regex("(^[0-9{4}])")
    var carprice= arrayListOf<Double>(carcount){0}
    var carrange= arrayListOf<Int>(carcount){0}
    val carrange11 = Regex("(^[0-9])")
    var carnum= hashMapOf<Int,String>(carcount)

    for (i in 1 .. carcount) {
        println("Please enter car type. ")
        cartype[i]= readLine()!!
        for (i in 1 .. 2) {
            if(cartype11.matches(cartype)){
                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 (var i in 1 .. 2) {
    if(caryear11.matches(caryear)){
        println("thank you")
        i++
    }
    else {
        println("please enter correct car year")
    }
}
        println("Please enter car price. ")
        carprice[i]= readLine()!!.toDouble()
        println("Please enter car range. ")
        carrange[i]= readLine()!!.toInt()
        for (var i in 1 .. 2) {
            if(carrange11.matches(carrange)){
                println("thank you")
                i++
            }
            else {
                println("please enter correct car range")
            }
        }
        println("Please enter the car num. ")
        carnum.add(carnum.get(readLine()!!.toInt()).toString())

    }
            }