Question 1 : (Solve quadratic equations) The two roots of a quadratic equation ax² + bx + c = 0 can be obtained using the following formula : -b + Vb – 4ac -b – VB – 4ac 4ас and 2 2а 2a b2 - 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 Equation.java for solving a quadratic equation 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". Note that you can use Math.pow(x, 0.5) to compute the discriminant. Here are some sample runs. Enter a, b, c: 1.0 3 1 -Enter The equation has two roots -0.381966 and -2.61803 Enter a, b, c: 1 2.0 1 -tnter The equation has one root -1 Enter a, b, c: 1 2 3 -Enter The equation has no real roots

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.7: Do While Loops
Problem 6E: (Numerical analysis) Here’s a challenging problem for those who know a little calculus. The...
icon
Related questions
Question
Question 1 : (Solve quadratic equations)
The two roots of a quadratic equation ax? + bx + c = 0 can be obtained using the following
formula :
-b + V² – 4ac
-b – Vb – 4ac
and n =
2a
2a
b² - 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 Equation.java for solving a quadratic equation 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".
Note that you can use Math.pow(x, 0.5) to compute the discriminant. Here are some
sample runs.
Enter a, b, c: 1.0 3 1 -Enter
The equation has two roots -0.381966 and -2.61803
Enter a, b, c: 1 2.0 1 -Enter
The equation has one root -1
Enter a, b, c: 1 2 3 -Enter
The equation has no real roots
Transcribed Image Text:Question 1 : (Solve quadratic equations) The two roots of a quadratic equation ax? + bx + c = 0 can be obtained using the following formula : -b + V² – 4ac -b – Vb – 4ac and n = 2a 2a b² - 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 Equation.java for solving a quadratic equation 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". Note that you can use Math.pow(x, 0.5) to compute the discriminant. Here are some sample runs. Enter a, b, c: 1.0 3 1 -Enter The equation has two roots -0.381966 and -2.61803 Enter a, b, c: 1 2.0 1 -Enter The equation has one root -1 Enter a, b, c: 1 2 3 -Enter The equation has no real roots
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr