Submitted by: Submitted by wate123
Views: 10
Words: 930
Pages: 4
Category: Science and Technology
Date Submitted: 07/01/2016 11:48 AM
Quadratic Solver
CSc 1350: Programming Project # 2
Solving Quadratic Equations
Out: 9/21
Due: 10/6 by 11:50 PM
Learning Objectives
• Using Conditional Statements,
• Using Logical Operators,
• Using Standard Math Class methods,
• Using Basic Arithmetic Operators, and
• More on Writing Interactive Programs
Definition 1. A Quadratic Equation is a second-order polynomial equation in a single variable x.
ax2 + bx + c = 0
(1)
with a = 0. a is referred to as the coefficient of the quadratic term, b, the
coefficient of the linear term, and c, the constant term. Because a quadratic
equation is a second-order polynomial equation, the fundamental theorem of
algebra guarantees that it has two solutions. These solutions may be both
real, or both complex.
Definition 2. The quantity D = b2 − 4ac is called the discriminant of a
quadratic equation.
Since we have covered decision statements, we will consider quadratic equations whose roots are real or complex numbers.
Duncan
1
Fall 2015
Quadratic Solver
CSc 1350: Programming Project # 2
For any quadratic equation, its roots may fall into one of these categories:
1. The discriminant, D, is 0:
x=
−b
2a
2. The discriminant, D, is positive:
x=
√
√
−b + D −b − D
,
2a
2a
3. The discriminant, D, is negative:
x=
−b
+
2a
|D| −b
i,
−
2a
2a
|D|
i
2a
where, i is a symbol representing the imaginary number.
Observe that when the discriminant is a negative number, the roots of the
quadratic equation are complex numbers. When the discriminant is 0, the
roots of the quadratic equation are identical and real. When the discriminant
is a positive number, the roots of the quadratic equation are distinct real
numbers.
Write a Java program that prompts the user for the coefficient of the
quadratic term, the coefficient of the linear term, and the constant term of a
quadratic equation. If the coefficient of the quadratic term is 0, your program
prints a message...