Complete Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

Answer:

No.

Complete Program

Here is the complete program, suitable for copying and pasting to your own source file. The file should be called SnowFlake.java.

// SnowFlake.java
//
import java.applet.Applet ;
import java.awt.* ;
import java.lang.Math ;

public class SnowFlake extends Applet
{
  Graphics graph;
   
  private void drawStar( int x, int y, int size )
  {
    int endX ;
    int endY ;
    
    if ( size <= 2 ) return;
    
    // Six lines radiating from (x,y)
    for ( int i = 0; i<6; i++ )
    {
      endX = x + (int)(size*Math.cos( (2*Math.PI/6)*i ));
      endY = y - (int)(size*Math.sin( (2*Math.PI/6)*i ));
      graph.drawLine( x, y, endX, endY );
      drawStar( endX, endY, size/3 );
    }
  }
         
  public void paint ( Graphics gr )
  { 
    graph      = gr;
    int width  = getSize().width;
    int height = getSize().height;
    int min;
    
    setBackground( Color.white );
    gr.setColor  ( Color.blue  );
    
    if ( height < width )
      min = height;
    else
      min = width;
      
    drawStar( width/2, height/2, min/4 );
  }
}

QUESTION 14:

To run this program, what else do you need?