The program that computes the discriminant for the equation
4x + 5 = 0 is:
Class Name: Exercise01_01Extra
public class Exercise01_01Extra {
public static void main(String[] args) {
System.out.println(4 4 - 4 3 * 5);
}
}
It can also be done with:
Python
class Exercise01_01Extra:
def discriminant(self, a, b, c):
"""
Calculates the discriminant of a quadratic equation ax^2 + bx + c = 0
"""
discriminant = b ** 2 - 4 * a * c
return discriminant
if __name__ == "__main__":
# Create an instance of the class
exercise = Exercise01_01Extra()
# Assign coefficients of the quadratic equation
a = 3
b = 4
c = 5
# Calculate the discriminant
discriminant = exercise.discriminant(a, b, c)
# Print the discriminant
print("The discriminant is:", discriminant)