Page 1 of 1

This assignment requires you to solve quadratic equations using the quadratic formula. You will need to write at least t

Posted: Sun Jul 03, 2022 11:24 am
by answerhappygod
This Assignment Requires You To Solve Quadratic Equations Using The Quadratic Formula You Will Need To Write At Least T 1
This Assignment Requires You To Solve Quadratic Equations Using The Quadratic Formula You Will Need To Write At Least T 1 (161.83 KiB) Viewed 30 times
This assignment requires you to solve quadratic equations using the quadratic formula. You will need to write at least three functions and apply a three-way conditional statement. Ask the user for the coefficients a, b and c of a quadratic equation ax²+bx+c=0 Implement solving for the roots -b±√(b²-4ac)/2a of the quadratic equation. If there is only one root, print it. If the roots are complex, print an error message. For more information on how this would work take a look at this website: https://www.calculatorsoup.com/calculat ... ulator.php You are required to: • Write a function to determine and return the determinant b²-4ac from the coefficients. (Hint: This function will make it easy for you t tell how many roots the equation has...) • Write a function to determine and return the first root from the coefficients. • Write a function to determine and return the second root from the coefficients. It's up to you how to put together the conditions and output from there. Submit your file as quad.c. Example runs: ==================== RESTART: C:/Users/matth/Desktop/quad.py =================== Enter coefficient a: 2.0 Enter coefficient b: 4.0 Enter coefficient c: 2.0 That quadratic has one root: -1.0
==================== RESTART: C:/Users/matth/Desktop/quad.py Enter coefficient a: 2.0 Enter coefficient b: 4.0 Enter coefficient c: 2.0 That quadratic has one root: -1.0 >>> ========= ======== RESTART: C:/Users/matth/Desktop/quad.py Enter coefficient a: 2.0 Enter coefficient b: 3.0 Enter coefficient c: 2.0 Sorry, that quadratic has complex roots. >>> =================== =================== ====== ============== RESTART: C:/Users/matth/Desktop/quad.py =================== Enter coefficient a: 2.0 Enter coefficient b: 5.0 Enter coefficient c: 2.0 That quadratic has two roots: -0.5 and -2.0 >>> ● ==================== RESTART: C:/Users/matth/Desktop/quad.py Enter coefficient a: 3.0 Enter coefficient b: 8.0 Enter coefficient c: 2.0 That quadratic has two roots: -0.2792407799438735 and -2.3874258867227933 =================== Rubric (No late penalty will be assigned for this project only) • Header Comment - 1 point • Code/Presentation/Comments - 1 point • Takes in input as a float - 1 point • Takes in all three values and saves them as variables - 1 point • Outputs a calculated value - 1 point Program detects if there is no roots - 1 point