-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise20.java
More file actions
18 lines (17 loc) · 1015 Bytes
/
Exercise20.java
File metadata and controls
18 lines (17 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Exercise20 {
public static void main(String arg[]) {
// Write a program that solves quadratic equations. The program should
// ask the user to input three numbers, a, b, and c, representing
// the three coefficients of a quadratic equation. The
// program should then calculate the determinant d (recall the
// formula for this is: "b squared" minus "four a times c".
// If d is negative, there are no real solutions to the quadratic equation,
// so the program should print a message saying so.
// If d is zero, there is only one real solution to the quadratic equation,
// so the program should print a message saying so, along with
// the solution (in this case, the solution is: "negative b divided by a").
// Otherwise, if d is positive, there are two real solutions, and the
// program should print them both (here the two solutions are:
// "minus b, plus or minus the square root of d, all over 2a").
}
}