Ahmed Aljailni

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.8 kB
2
Indexable
Never
fun main()
{
    var carname = ArrayListOf<String>()
    var carmodel = ArrayListOf<Int>()
    var carprice = ArrayListOf<Double>()
    var carkilo = ArrayListOf<Int>()
    var x=1
    var counter=0
    var car=0
    var prices=0
    var modeling= Regex("([0-9]{4})")
    var name_car = Regex("([a-zA-Z])")

    while (x != 0)
    {
        Println("Enter the name of car : ")
        var carr= readLine()!!.toString()
        carname.add(carr)


        println("Enter the Model of car : ")
        var model= readLine()!!.toInt()

         while (!modeling.matches(model)) {
             println("Enter the correct Model of car : ")
             model= readLine()!!.toInt()

         }
        carmodel.add(model)


        println("Enter the Price for Car: ")
        var price = readLine()!!.toDouble()
        carprice.add(price)

        println("Enter How many Killo used : ")
        var kilo = readLine().toInt()
        carkilo.add(kilo)
    }

    var option=1
    while ( option != 0){
        println("kindly choose : \n 1-Print all cars \n 2-Print all cars by prices range \n " +
                "3-Print all cars By How many kilo used \n 4- make discount \n 5-Print How much car we have \n" +
                "6- Print How much for all cars \n 7-print all cars by Model \n 8- Print all cars by names \n 0- to Exit" )

      var checking = readLine()!!.toInt()
        when(checking)
        {
            0->option=0

            1>- for (i in 0 until carname.size){
                println("Car Name : "+carname[i] + "\n car Model : "+carmodel[i] "\n car price : "+carprice[i] "\n kilo : "+carkilo[i])
            }

            2-> println("Please Enter the High Price you want : ")
            var H_car= readLine()!!.toInt()
            println("Please Enter the Low Price you want : ")
            var L_car= readLine()!!.toInt()
            for (i in 0 until carprice.size)
            {
                if (L_car <= carprice[i] && H_car >= carprice[i])
                    println("Car Name : "+carname[i] + "\n car Model : "+carmodel[i] "\n car price : "+carprice[i] "\n kilo : "+carkilo[i])
            }
            3->    println("Please Enter the High Kilo you want : ")
                var H_kilo= readLine()!!.toInt()
            println("Please Enter the Low Kilo you want : ")
                var L_kilo= readLine()!!.toInt()
            for (i in 0 until carprice.size)
            {
                if (L_kilo <= carkilo[i] && H_kilo >= carkilo[i])
                    println("Car Name : "+carname[i] + "\n car Model : "+carmodel[i] "\n car price : "+carprice[i] "\n kilo : "+carkilo[i])
            }

            7-> println("Enter model you want ")    
        }

    }
}