// Quadratic3.java
//
// Outputs the value of a*x^2 + b*x + c
// where a, b, c, and x have been input
// by the user.
//
// Uses console input
import javax.swing.JOptionPane;
public class Quadratic3
{
public static void main(String[] args)
{
double a = Double.parseDouble(
JOptionPane.showInputDialog("Enter a:"));
double b = Double.parseDouble(
JOptionPane.showInputDialog("Enter b:"));
double c = Double.parseDouble(
JOptionPane.showInputDialog("Enter c:"));
double x = Double.parseDouble(
JOptionPane.showInputDialog("Enter x:"));
System.out.println("Given x = " + x + ", "
+ a + "*x^2" + " + " + b + "*x" + " + " + c
+ " = " + quadratic(a, b, c, x) + ".");
System.exit(0);
}
public static double quadratic(double a, double b, double c, double x)
{
return a*x*x + b*x + c;
}
}