Question: Question 01 : Write an interactive Java program that prompts for and reads the number n of quadratic equations to be solved. If n is
Question 01: Write an interactive Java program that prompts for and reads the number n of quadratic equations to be solved. If n is zero or negative, the program must loop until a positive value is entered. The program then prompts for and reads the constants a, b, and c of the quadratic equation ax2 + bx + c = 0, it then displays the real roots of each of the quadratic equation, if the solution exists; otherwise it displays appropriate error messages. Your program must also handle InputMismatchException.
The real roots x1 and x2 of a quadratic equation ax2 + bx + c = 0 can be calculated using the following formulas:
If both a and b are zero, there is no solution.
If a is zero, there is only one real root.
If the discriminant b2 4ac is negative, there are no real roots
If the discriminant b2 4ac is zero, there are two equal real roots
If the discriminant b2 4ac > 0, there are two distinct real roots
Sample program runs:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
