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
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]
Step by Step Solution
3.45 Rating (158 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started