subject

The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:

r1 = (-b + sqrt(b^2 - 4ac)) / (2a)

and

r2 = (-b - sqrt(b^2 - 4ac)) / (2a)

b^2 - 4ac is called the discriminant of the quadratic equation. if it is positive, the equation has two real roots. if it is zero, the equation has one root. if it is negative, the equation has no real roots.

write a program that prompts the user to enter values for a, b, and c and displays the result based on the discriminant.

if the discriminant is positive, display two roots.

if the discriminant is 0, display one root.

otherwise, display “the equation has no real roots”.

sample run 1

enter a: 1.0

enter b: 3

enter c: 1

the roots are -0.3819660112501051 and -2.618033988749895

sample run 2

enter a: 1

enter b: 2.0

enter c: 1

the root is -1.0

sample run 3

enter a: 1

enter b: 2

enter c: 3

the equation has no real roots

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:10
Assume that minutes is an int variable whose value is 0 or positive. write an expression whose value is "undercooked" or "soft-boiled" or "medium-boiled" or "hard-boiled" or "overcooked" based on the value of minutes. in particular: if the value of minutes is less than 2 the expression's value is "undercooked"; 2-4 would be a "soft-boiled", 5-7 would be "medium-boiled", 8-11 would be "hard-boiled" and 12 or more would be a "overcooked".
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
In my email i got a message it says a quick message and in message details on who its from its says nicole and under nicole is [email protected] -
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
question
Computers and Technology, 23.06.2019 08:30
When you interpret the behavior of others according to your experiences and understanding of the world your evaluation is
Answers: 1
You know the right answer?
The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:...
Questions
question
English, 10.06.2020 04:57
question
Chemistry, 10.06.2020 04:57
Questions on the website: 13722363