Logical2.java



/*Logical2.java
This applet will demonstrate the AND, OR, and NOT Logical Operators.
It illustrates this in conjuntion with if statements.

< applet
code=Logical2
width=250
height=250 >
< /applet >


*/

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

public class Logical2 extends Applet
{
  Label Line1 = new Label("This applet will demonstrate Logical Operators");
  Button ShowIt=new Button("Go");
  TextArea Result=new TextArea(10,35);
  public void init()
  {
  add(Line1);
  add(ShowIt);
  add(Result);
  }


  public boolean action (Event thisEvent, Object thisObject)
  {
    
      int a = 10;
      double r = -5.5;
      if (a < 20 | r > -10.2)
              Result.appendText("***\n");
      if (a >=20 | r <= -10)
	      Result.appendText("###\n");
      if (a != 10 & r == -5.5)
	      Result.appendText("???\n");
      if (a == 10 & r == -5.5);
	      Result.appendText("!!!\n");
      if ((a != 11 & r == -5.5) | (a+r) == 4.5)
	      Result.appendText("WWW");
  return true;

  }
}

Output for Logical2.java