import java.applet.Applet;
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import netscape.javascript.*;

/**
*
* DocWriter (C) 1996 by Paul A. Houle (ph18@cornell.edu)
*
* DocWriter,  like many good things in life,  is free.  You can find out
* more about DocWriter at
*
* http://www.msc.cornell.edu/~houle/javascript/DocWriter.html
*
* DocWriter uses LiveConnect to output a table of sines,  cosines,  and
* tangents to another browser window.  The user can then print the results
* or save them to a file.  LiveConnect is only available on Netscape 3.0
* as of the time of this writing.
*
*/

public class DocWriter extends Applet {

  Button GoButton;
  JSObject mozilla;

  public void init() {

  setBackground(Color.white);
  GoButton = new Button("Go!");
  add(GoButton);
  };

public boolean action(Event evt,Object what)
  {
  if (evt.target==GoButton) Go();

  return false;
  };

void Go()
{
  double angle;

  mozilla=JSObject.getWindow(this);

  mozilla.eval("myWindow = window.open('','displayWindow')");
  mozilla.eval("myWindow.document.open('text/html')");
  WriteDoc("<HEAD><TITLE>Sin/Cos/Tangent Table</TITLE></HEAD>");
  WriteDoc("<BODY><TABLE><TR><TD>Angle</TD><TD>Sin</TD><TD>Cos</TD><TD>Tan</TD></TR>");
  for(int i=0;i<90;i++)
  {

  angle = i * Math.PI / 180.0;     

  WriteDoc("<TR><TD>"+i+"</TD>");
  WriteDoc("<TD> "+Math.sin(angle)+"</TD>");
  WriteDoc("<TD> "+Math.cos(angle)+"</TD>");
  WriteDoc("<TD> "+Math.tan(angle)+"</TD></TR>");
  };

  WriteDoc("</TABLE></BODY>");

  /* if you don't call myWindow.document.close(),  the user will */
  /* not be able to print or save the document you wrote */

  mozilla.eval("myWindow.document.close()");

};

void WriteDoc(String s)
{
  mozilla.eval("myWindow.document.write('"+s+"')");
};

};










 
