PROGRAMMING:Solving quadratic equation of one variable
Programming to solve the root of the quadratic equation AX ^ 2 + BX + C = 0, requires a, B, C input from the keyboard.
The main class must have the following methods:
```
public static void main(String[] args);// Main method
public static int solveQuadratic(double[] eqn, double[] roots);// Eqn stores the three input coefficients a, B and C, and then stores the two real roots in roots. This method returns the number of real roots.
```
###Input format:
Enter the values of the three coefficients of the quadratic equation of one variable (all real numbers) from the keyboard, which can be separated by one or more spaces or carriage returns.
###Output format:
1. When the input data is illegal, output "wrong format"
1. When there is no real root, output the following string "the equation has no roots";
1. When there is only one root, the output format is "the equation has one root: value"( Note that the output value must have four decimal places and a space in front of the value)
1. When there are two roots, enter the format "the equation has two roots: value 1 and value 2"( Note that the output value must have four decimal places and a space in front of the value)
###Input sample 1:
Here is a set of inputs. For example:
```in
2 6 -554
```
###Output sample 1:
The corresponding output is given here. For example:
```out
The equation has two roots: 15.2108 and -18.2108
```
###Input sample 2:
Here is a set of inputs. For example:
```in
300.0 0.0 0.00
```
###Output sample 2:
The corresponding output is given here. For example:
```out
The equation has one root: 0.0000
```
answer:If there is no answer, please comment
(1) How to use it;
(2) One dimensional array is used;
(3) Use sstring. Format (string, value); method
(4) Note the passing of array parameters.
The main class must have the following methods:
```
public static void main(String[] args);// Main method
public static int solveQuadratic(double[] eqn, double[] roots);// Eqn stores the three input coefficients a, B and C, and then stores the two real roots in roots. This method returns the number of real roots.
```
###Input format:
Enter the values of the three coefficients of the quadratic equation of one variable (all real numbers) from the keyboard, which can be separated by one or more spaces or carriage returns.
###Output format:
1. When the input data is illegal, output "wrong format"
1. When there is no real root, output the following string "the equation has no roots";
1. When there is only one root, the output format is "the equation has one root: value"( Note that the output value must have four decimal places and a space in front of the value)
1. When there are two roots, enter the format "the equation has two roots: value 1 and value 2"( Note that the output value must have four decimal places and a space in front of the value)
###Input sample 1:
Here is a set of inputs. For example:
```in
2 6 -554
```
###Output sample 1:
The corresponding output is given here. For example:
```out
The equation has two roots: 15.2108 and -18.2108
```
###Input sample 2:
Here is a set of inputs. For example:
```in
300.0 0.0 0.00
```
###Output sample 2:
The corresponding output is given here. For example:
```out
The equation has one root: 0.0000
```
answer:If there is no answer, please comment
(1) How to use it;
(2) One dimensional array is used;
(3) Use sstring. Format (string, value); method
(4) Note the passing of array parameters.