Pure Programmer
Blue Matrix


Cluster Map

Project: Quadradic Equations

Write a program that computes the value of the [[quadratic equation]] y = ax² + bx + c. Used named constants for a, b and c and use variables for x and y. Initially set a, b and c to 3, 2 and 1 respectively then print out y for x = 0,1,2 and 3. Use the increment operator ++ to change your x variable before each successive computation of y. Then try changing the values of a, b and c to compute different quadratic equation.

Output
$ javac -Xlint QuadraticEquations.java $ java -ea QuadraticEquations f(0.00000) = 1.00000 f(1.00000) = 6.00000 f(2.00000) = 17.0000 f(3.00000) = 34.0000

Solution