Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.5 kB
2
Indexable
Never
fun main () {
    var cars = arrayListOf<String>()
    var yearofcar = arrayListOf<Int>()
    var typeofcar = arrayListOf<String>()
    var price = arrayListOf<Int>()
    var killo = arrayListOf<Int>()
    var pincars = hashMapOf<Int, String>()
    var whilecontrol =1
//    println("How many cars? : ")
//    var countcar = readLine()!!.toInt()

    while (whilecontrol != 0) {
    print("Enter the name of car: ")
    var carname = readLine()!!.toString()
    cars.add(carname)

    print("Enter the year of car: ")
    yearofcar.add(readLine()!!.toInt())

    print("Enter the type of car: ")
    typeofcar.add(readLine()!!.toString())

    print("Enter the price of car: ")
    price.add(readLine()!!.toInt())

    print("Enter the killos of car: ")
    killo.add(readLine()!!.toInt())

    print("Enter the pincar: ")
    var valu = readLine()!!.toInt()
    pincars.put(valu,carname)

    print("enter 0 to exit or enter any number to add another cars !!")
        whilecontrol = readLine()!!.toInt()
    }

    print("Press 1 to show all cars information\n")
    var info = readLine()!!.toInt()
    when (info) {

        1 -> {
            for (i in 0 until cars.size) {
                println("Car name: " + cars[i] + "\n" + "Car year: " + yearofcar[i] + "\n" + "Car price: " + price[i] + "\n" + "The car killos: " + killo[i] + "\n" + "Car name: " + cars[i] + "\n" + "The Pin car: " + pincars[i] + "\n")
            }
        }

            }

}