CIS 790 PASSING PARAMETERS THRU HTML
PROF. AUCIELLO

-- Math Exponentiation --

Following is the Java Source Code (param5.java)

The Java Boutique is an Industry-Sponsored WebSite for the purpose of promoting Java and related applications. It has support from Sun Microsystems, the developer of Java -- which ensures the accuracy and relevance of the software presented.
Source: http://javaboutique.internet.com

Recommended that you use this site as an "electronic reference book" as well as to understand and optimize your Java Assignments.
JA. 10.14.2001.

Passing Parameters that control or modify behavior of applet is truly an innovative and interactive way to program. If an applet uses variables to control speed, names of music files (au), names of image files (.jpg), color, or postition or whatever, you, the programmer, can modify those variables by passing their values thru the HTML that runs the applet! This allows a "robust" and "user-friendly" applet. This state-of-the-art feature has become a standard for applet programming!

*/ 

//   CIS 790          Passing HTML Parameters          PROF.  AUCIELLO  
//   (  param5.java  )                 
//   Applet based on example from  Java Boutique  (follows)

     import java.awt.*; 
     import java.applet.*; 
     import java.lang.Math;

     public class param5 extends Applet 
       {  String parameter1;   // save 1st HTM param as String.
          int parameter2;      // 2nd & 3rd parameters defined as integer.
          int parameter3; 
          double result;       // contains result of equation.

          public void init()  
            {  parameter1 = getParameter("param1"); 
                               // getParameter  "gets"  its  value from HTML
               parameter2 = Integer.parseInt(getParameter("param2")); 
                               // This statement "showcases" power of Java:
                               //  param2 is passed, then converted (parsed)
                               //  into an Integer.   Note nested methods 
                               //  (functions).  Parameters are obviously 
                               //  passed as text, explaining need to 
                               //  convert them.
               parameter3 =  Integer.parseInt(getParameter("param3")); 
               result     =  Math.pow(parameter2, parameter3);
                               // use Math.pow(a,n) function. 
                               //Import java.lang package for Math functions
            } // ends init()

          public void paint(Graphics g)  
            { g.drawString("Parameter 1 is: " +  parameter1,20,20); 
              g.drawString("Parameter 2 is: " +   parameter2,20,40); 
              g.drawString("Parameter 3 is: " +   parameter3,20,60); 
              g.drawString(parameter2 + "exponentiated by " + parameter3 +
                           " = " + result,20,80); 
            }  // ends paint()
       }  // ends applet

100 points. for typing this in and clean compile.
100 comment each line thoroughly in your words.
100 for adding (2) other Math methods (sq root and 1 other). Think -- you know the code for this!
100 for posting this on your web site.


Here is param5.htm: <html> <h3> CIS 790 Math Exponentiation by Emily Tran </h3> <APPLET CODE ="param5" WIDTH=400 HEIGHT=150> <param name="param1" value="Exponentiation -- Title passed from HTML"> <param name="param2" value="2"> <param name="param3" value="10"> </APPLET> </html> */