MathClass.java


//MathClass.java

/*

< applet
code=MathClass
width=200
height=200 >
< /applet >

This applet will demonstrate the following methods from the Math Class :
  round, min, max, ceil, and floor.
  It will also illustrate integer division and the Mod 
  operation.*/

import java.applet.*;
import java.awt.*;

public class MathClass extends Applet
{
  Button Calculate = new Button("Calculate");
  TextArea result = new TextArea(5,25);

  public void init()
  {
    add (Calculate);
    add(result);

   }

public boolean action (Event thisEvent, Object thisObject)
{
  double num1 = 25.0 / 4; // Float Division.
  long num2 = Math.round(num1); // Rounds the double argument to the nearest Integer.
  int num3 = 16 / 5;  // Integer Division. 16 / 5 = 3
  int num4 = 12 % 7; // Mod Division takes the remainder.
  int num5 = Math.max(num3, num4);  // Finds the maximum argument.
  int num6 = Math.min(num3, num4);  // Finds the minimum argument.
  double num7 = num1 + 0.5;
  double num8 = Math.ceil(num7); // Finds the smallest Int greater than the argument.
  double num9 = Math.floor(num7); //Finds the largest Int smaller than the argument.
  result.appendText("quotient ="+num1+"\n rounded quotient = "+num2+"\n max = "+num5+"\n min = "+num6+"\n Smallest Integer = "+num8+"\n Greatest Integer = "+num9+"");
  
  return true;
}
}

Sample Output for MathClass.java