(Algebra: solve quadratic equations) The two roots of a quadratic equation ax + bx + c = 0 can be obtained using the following formula: -b + Vb – 4ac and -b – Vb? rɔ = 4ас | 2a 2a 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"

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 33SA
icon
Related questions
Question

3.1 Please take screenshots show the steps and results.

缩放视图:点击屏幕的左侧或右侧
可翻页。
Debugging Tip
Before you ask for help, read and explain the program to yourself, and trace it using
several representative inputs by hand or using an IDE debugger. You learn how to
program by debugging your own mistakes.
learn f
ion 3.2
3.1
(Algebra: 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 r2
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 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
6.
has no real roots".
Note that you can use Math.pow(x, 0.5) to compute Vx. Here are some
sample runs.
||
||
Transcribed Image Text:缩放视图:点击屏幕的左侧或右侧 可翻页。 Debugging Tip Before you ask for help, read and explain the program to yourself, and trace it using several representative inputs by hand or using an IDE debugger. You learn how to program by debugging your own mistakes. learn f ion 3.2 3.1 (Algebra: 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 r2 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 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 6. has no real roots". Note that you can use Math.pow(x, 0.5) to compute Vx. Here are some sample runs. || ||
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning