import kotlin.system.exitProcessimport java.lang.Double.parseDouble
fun main(args: Array<String>) { println("-Welcome To The Program Package Prepared By The Legend Yahia Nasrallah-\n") println("1- Square number calculation program \n 2-Value calculation program x*y \n 3-Welcome screen program from your city \n 4-Exit the software package \n ") print("Enter the number of app you need :")
var z = readLine()!!.toString() while (isnumber(z)) { if (z!!.toInt() == 1) { print("Enter the number:") var n = readLine()!!.toString() if (isnumber(n)) println("Number square $n :" + square(n)) else println("Bad Number") } else if (z!!.toInt() == 2) { print("Enter number 1 :") var x = readLine()!!.toString() print("Enter number 2 :") var y = readLine()!!.toString() if (isnumber(x) and isnumber(y)) println("sum of $x*$y=" + sum(y, x)) else println("Bad Number") } else if (z!!.toInt() == 3) { print("Enter your name :")
var m: String = readLine()!!.toString()
print("Enter your age :")
var a: String = readLine()!!.toString() checkmth18(a, m)
} else {
println("Thanks for trying the program") exitProcess(0)
} println("\n\nWelcome Back .. Enter the number of app you need :") z= readLine()!!.toString() }}
fun square(n:String):Int{ return (n!!.toInt()*n!!.toInt())}fun sum(y:String,x:String):Int{ return (y!!.toInt()*x!!.toInt())}
fun checkmth18( age:String, m:String){ if (isnumber(age)) { if (age!!.toInt() >=18) println("Hello Mr. $m") else if (age!!.toInt() <18) println("Hello $m") } else print("Bad Number")}
fun isnumber(z :String) :Boolean{
try { val num = parseDouble(z) } catch (e: NumberFormatException) { return false } return true}