Question: This week we will write a Java program that can solve the quadratic equation. Recall the quadratic formula solves a x 2 + b x

This week we will write a Java program that can solve the quadratic equation.
Recall the quadratic formula solves ax2+bx+c=0 whenever a0. In case no one has done you the proper service of deriving the formula, please allow me.
ax2+bx+c=0
Longrightarrowx2+bax+ca=0
Longrightarrowx2+bax=-ca
Longrightarrowx2+bax+(b2a)2=-ca+(b2a)2
Longrightarrow(x+b2a)2=-ca+(b2a)2
Longrightarrow(x+b2a)2=b2-4ac4a2
Longrightarrow+b2a=+-b-4ac22a
Longrightarrowx=-b2a+-b-4ac22a
Longrightarrowx=-b+-b2-4ac22a
divide both sides of eq. by a
subtracting constant term
completing the square
factoring left-hand side of equation
combine right-hand side terms
taking square root of both sides
subtracting constant term
et voil!
Notice that the term under the square root, =b2-4ac, says a lot about the solution. We call this term the discriminant.
If >0, we are guaranteed two real solutions
Else if =0, we have two solutions technically, but they are repeated
Else, it must be the case that 0 which implies there are two solutions that are complex numbers (as they involve i=-12)
I am providing a Java file darr that calculates the discriminant. You will be adding the logic that can store a user's input into the variables a,b and c.
Given the sign of the discriminant, add the appropriate "if", "else if", "else" statements that tell the user what the solutions are. Here are a few examples:
 This week we will write a Java program that can solve

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!