sub evaluate_delta_and_answer {
my($x,$y,$z) = @_;
if ($x != 0) {
$delta = ($y**2 - (4 * $x * $z));
if ($delta < 0) {
print "b^2-4ac is less than zero. Both roots undefined.\n\n";
print "Program Terminated. Goodbye, Dave.\n\n"
}
elsif ($delta == 0) {
$root = (0 - $y) /(2 * $x );
print "b^2-4ac = 0. There will be only one root: " . $root . "\n\n";
print "Goodbye, Dave.\n\n";
}
elsif ($delta > 0) {
print "b^2-4ac > 0. There will be two roots.\n\n";
$root1 = ((0 - $y) - ($delta)**(0.5)) / (2 * $x);
$root2 = ((0 - $y) + ($delta)**(0.5)) / (2 * $x);
print "The first root, x1 = " . $root1 . "\n\n";
print "The second root, x2 = " . $root2 . "\n\n";
print "Goodbye, Dave.\n\n";
}
}
else {
print "a = 0. This is not a quadratic function.\n";
print "Goodbye, Dave.\n";
}
}