public class QuadraticEquation { // a quadratic equation a*x^2 + b*x + c = 0 double a; double b; double c; QuadraticEquation(double a1, double b1, double c1) { // create a new quadratic equation with the given coefficients a = a1; b = b1; c = c1; } void print() { // print the equation to the screen System.out.println(a + "*x^2 + "+ b + "*x + " + c); } }
public class TestQuadraticEquation { // simple test program for QuadraticEquation public static void main (String[] args) { QuadraticEquation qe1 = new QuadraticEquation(2.0, 10.0, 12.0); qe1.print(); } }