import java.awt.*; import javax.swing.*; public class Parabola extends JApplet { @Override public void paint(Graphics g) { super.paint(g); double a = -0.0025, b = 1, c = 0; for (int x0 = 0; x0 < 200; x0 += 10) { double y0 = a * x0 * x0 + b * x0 + c; int x1 = x0 + 10; double y1 = a * x1 * x1 + b * x1 + c; g.drawLine(x0, (int)y0, x1, (int)y1); System.out.printf("(%d, %.1f) -- (%d, %.1f)", x0, y0, x1, y1); } } public static void main(String[] args) { JFrame frame = new JFrame(""); JApplet applet = new Parabola(); applet.setPreferredSize(new Dimension(200, 200)); frame.add(applet); frame.pack(); frame.setVisible(true); applet.init(); applet.start(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }