Write a program that prompts the user to specify the coefficients of a quadratic equation and then
Question:
Write a program that prompts the user to specify the coefficients of a quadratic equation and then calculates the roots of the quadratic equation.
It prints out the roots of the quadratic equation. The marking rubric only applies to compilable code.
•The program must use an array to store the coefficients of a quadratic equation. [1]
•The program obtains the coefficients of a quadratic equation from the command line. [1]
•If the coefficient is 0 then specify this in the command line, for example, quadratic.exe 1 0 -4. [1]
•The program must check that the correct number of input arguments is entered and display an error message if the incorrect number of arguments is entered. [2]
•The program must use a for loop to store the coefficients in an array. [4]
•The program must define and call a function called calc_roots with the coefficient array as input arguments. The function returns no value. Define local variables. [2]
•The function calc_roots must calculate the roots of the quadratic equation. [3]
•USe if statements to check if the calculated root values are negative and then display the root as either (x -r) or (x + r), where r is the calculated root. [4]
•The program structure and use of libraries are correct. [2]
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang