import acm.program.*;
public class Quadratic extends ConsoleProgram {
public void run() {
/ You fill this in /
showMessage();
findsolution();
}
private void showMessage() {
println("Enter coefficients for the quadratic equation:");
}
private void findsolution() {
int a = readInt("Enter a: ");
int b = readInt("Enter b: ");
int c = readInt("Enter c: ");
double x1 = (-b + Math.sqrt(b*b-4*a*c))/(2*a);
double x2 = (-b - Math.sqrt(b*b-4*a*c))/(2*a);
println("The first solution is " + x1 + ".");
println("The second solution is " + x2 + ".");
}
}