// WhileDemo.java
// APPLET CODE="WhileDemo" HEIGHT=300 WIDTH=200
// Prints a column of integers and their squares and cubes
import java.awt.*;
import javax.swing.*;

public class WhileDemo extends JApplet {
	int n, s, c;
	int xPos, yPos;	// coordinates of the drawString

	public void init( ) {
		n = 0;
		s = 0;
		c = 0;
		xPos = 0;
		yPos = 20;
	}

	public void paint( Graphics g ) {
		g.drawString( "number", xPos, yPos );
		g.drawString( "square", xPos + 50, yPos );
		g.drawString( "cube", xPos + 100, yPos );

		yPos = yPos + 25;

		while ( n <= 10 ) {
			s = n * n;
			c = n * n * n;
			g.drawString( "" + n, xPos, yPos );
			g.drawString( "" + s, xPos + 50, yPos );
			g.drawString( "" + c, xPos + 100, yPos );

			n = n + 1;
			yPos = yPos + 25;
		}
	}
}