Mohanad Aljhani
unknown
plain_text
3 years ago
3.2 kB
3
Indexable
fun main (args:Array<String>) {
var car_type = arrayListOf<String>()
var prod_year = arrayListOf<Double>()
var price = arrayListOf<String>()
var km = arrayListOf<String>()
var x = 1
var i = 0
val km1 = Regex("\\{0,4}\\d{4}")
while (x != 0) {
var car_type = ""
var prod_year = ""
var price = ""
var km = ""
println("enter the type of car no. " + (i + 1))
car_type.add(readLine()!!.toString())
println("enter the prod_year of car no. " + (i + 1))
prod_year.add(readLine()!!.toDouble())
println("enter the price of car no. " + (i + 1))
while (km1.matches(km) == false) {
km = readLine()!!.toint()
if (!km1.matches(km))
println("enter a correct km !!")
}
km.add(km)
var counter=0;
println(
"choose from the following:\n 1- to print out the full data of car\n 2-to print out" +
"a list of the cars names with prod above 10,000\n 3-to print out a list of the cars prod and their price \n" +
" 4-to print out a list of the cars names with price more than 80\n 5-to print out a list of the cars typs and their pric\n" +
" 6-to print out a list of the cars names and their km\n 7-to print out a list of the cars type" +
"and their prod year "
)
var k = 1
var stop='r'
do {
var option = readLine()!!.toInt()
when (option) {
1 -> for (i in 0 until car_type.size) {
println("the full data of the employee no: $k\n" + car_type[i] + " " + prod_year[i] + " " + km[i] + " " + price[i] + "\n")
println("-----------------------------")
k++
}
2 -> {
println("enter a range of km: ")
var from = readLine()!!.toDouble()
var to = readLine()!!.toDouble()
for (i in 0 until km.size)
if (km[i].toDouble() in from..to) println(car_type[i] + " " + price[i])
}
3 -> for (i in 0 until car_type.size)
println(car_type[i] + " " + price[i])
4 -> {
println("enter a range of pric: ")
var from = readLine()!!.toInt()
var to = readLine()!!.toInt()
for (i in 0 until price.size)
if (price[i] in from..to) println(car_type[i] + " " + price[i])
}
5 -> for (i in 0 until car_type.size)
println(car_type[i] + " " + km[i])
6 -> for (i in 0 until km.size)
println(car_type[i] + " " + prod_year[i] * (((price[i] / 20) / 100) * 12))
7 -> for (i in 0 until car_type.size)
println(car_type[i] + " " + price[i] * 12)
else -> println("ENTER A CORRECT price !\nOR N to STOP")
}
println("do you want to make another enquiry ?\nY/N")
stop= readLine()!!.single()
}
while (stop == 'Y' || stop=='y')}}
Editor is loading...