xxxxxxxxxx
object StockPriceValidator {
def isValidPrice(price: Double): Boolean = {
// Define your price validation criteria here
// For example, check if the price is non-negative and within a reasonable range
price >= 0 && price <= 1000 // Adjust the range as needed
}
def main(args: Array[String]): Unit = {
val price1 = 50.0
val price2 = -10.0
println(s"Is $price1 a valid price? ${isValidPrice(price1)}")
println(s"Is $price2 a valid price? ${isValidPrice(price2)}")
}
}