public class IntegrateAccel4 { public static void main (String[] argv) { // Make the object. Function velocityCurve = new Function ("velocity"); for (double end=0.1; end<=10; end+=0.1) { // Compute final velocity at desired x-value: double finalVelocity = computeFinalVelocity (4.9, 0, 0, end, 0.1); // Put the (x,y) values into the object. velocityCurve.add (end, finalVelocity); } // Display. velocityCurve.show (); } public static double computeFinalVelocity (double a, double initialVelocity, double initialTime, double endTime, double s) { double v = initialVelocity; double t = initialTime; while (t < endTime) { // Update velocity: v = v + s * a; // Update time: t = t + s; } return v; } }