import java.text.DecimalFormat
import kotlin.math.roundToInt
fun main (args:Array<String>) {
print ("Enter the number.: ")
}
var Car Type = arrayListOf<String>()
var Model = arrayListOf<Int>()
var manufacturing year = arrayListOf<Int>()
var price = arrayListOf<Int>()
var mileage counter = arrayListOf<Int>()
var chassis number = hashmap<Int>()
var x = 1
var i = 0
val email_RE = Regex("([a-zA-Z0-9_.+-]{2,25}+@[a-zA-Z0-9-]{5,12}+\\.[a-zA-Z0-9-.]{2,3})")
val phone_RE = Regex("\\+[0-9]{2,4}\\d{9}")
while (x != 0) {
var email = ""
var phone = ""
var assess = -1
println("enter the name of employee no. " + (i + 1))
names.add(readLine()!!)
println("enter the salary of employee no. " + (i + 1))
salaries.add(readLine()!!.toDouble())
println("enter the email of employee no. " + (i + 1))
while (email_RE.matches(email) == false) {
email = readLine()!!.toString()
if (!email_RE.matches(email))
println("enter a correct email !!")
}
emails.add(email)
var counter=0;
println("enter the mobile number of employee no." + (i + 1))
while (phone_RE.matches(phone) == false) {
phone = readLine()!!
if (!phone_RE.matches(phone)){
println("enter a correct mobile number !!")
counter++
if (counter>2) println("You should enter the national code with + first")
}
}
mobiles.add(phone)
println("enter the assessment of employee no." + (i + 1))
while (assess < 0 || assess > 100) {
assess = readLine()!!.toInt()
if (assess < 0 || assess > 100)
println("enter a correct evaluation mark !!")
}
assessment.add(assess)
println("PRESS 0 TO STOP\nANY KEY TO CONTINUE")
x = readLine()!!.toInt()
i++
}
println(
"choose from the following:\n 1- to print out the full data of employees\n 2-to print out" +
"a list of the employee names with salaries above 10,000\n 3-to print out a list of the employee names and their mobile numbers\n" +
" 4-to print out a list of the employee names with evaluation more than 80\n 5-to print out a list of the employee names and their emails\n" +
" 6-to print out a list of the employee names and their commissions\n 7-to print out a list of the employee names" +
"and their annual salaries"
)
var k = 1
var stop='r'
do {
var option = readLine()!!.toInt()
when (option) {
1 -> for (i in 0 until mobiles.size) {
println("the full data of the employee no: $k\n" + names[i] + " " + salaries[i] + " " + emails[i] + " " + mobiles[i] + " " + assessment[i] + "\n")
println("-----------------------------")
k++
}
2 -> {
println("enter a range of salaries: ")
var from = readLine()!!.toDouble()
var to = readLine()!!.toDouble()
for (i in 0 until mobiles.size)
if (salaries[i] in from..to) println(names[i] + " " + salaries[i])
}
3 -> for (i in 0 until mobiles.size)
println(names[i] + " " + mobiles[i])
4 -> {
println("enter a range of assessment: ")
var from = readLine()!!.toInt()
var to = readLine()!!.toInt()
for (i in 0 until mobiles.size)
if (assessment[i] in from..to) println(names[i] + " " + assessment[i])
}
5 -> for (i in 0 until mobiles.size)
println(names[i] + " " + emails[i])
6 -> {
var d = DecimalFormat("#")
for (i in 0 until mobiles.size)
println(names[i] + " " +d.format((((assessment[i].toDouble() / 20) / 100) * 12)*salaries[i]))
}
7 -> for (i in 0 until mobiles.size)
println(names[i] + " " + salaries[i] * 12)
else -> println("ENTER A CORRECT NUMBER !\nOR N to STOP")
}
println("do you want to make another enquiry ?\nY/N")
stop= readLine()!!.single()
} while (stop == 'Y' || stop=='y')
}