Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions