// // function to solve a*x*x + b*x + c = 0 // and print results // def roots(a : Double, b : Double, c : Double) = { if (a == 0.0) { if (b != 0.0) { val root = -c/b println("root is " + root) } else { println("a and b both zero. I give up!") } } else if ((b*b - 4*a*c) < 0) { println("no real roots") } else { val root1 = (-b + math.sqrt(b*b - 4*a*c))/(2*a) val root2 = (-b - math.sqrt(b*b - 4*a*c))/(2*a) println("root1 is " + root1) println("root2 is " + root2) } }