.

Friday 27 March 2015

Download program of LOGIC GATE IN JAVA

AND GATE

package logicgate;
 public class and
{
 int z1;
 public int dooperation(int x1,int y1)
 {
  int z;
  z=x1*y1;
  z1=z;
 return(z1);
}
 

 }

 NOT GATE
package logicgate;

 public class not
 {

 public int dooperation(int x3)
 {
  int z3;
  {
   if(x3==0)
   z3=1;
   else
   z3=0;
   return(z3);
 }
 }
  }


OR GATE
package logicgate;

 public class or
{
 int z2;
 public int dooperation(int x2,int y2)
 {
 int z;
 z=x2+y2;
 z2=z;
  return(z2);
 }
 
 }

MAIN CLASS


import logicgate.and;
import logicgate.or;
import logicgate.not;

 class Main
{
 public static void main(String[] arg)
{
 and ob1=new and();
 or ob2=new or();
 not ob3=new not();
 ob1.dooperation(0,1);
 ob2.dooperation(0,0);
 ob3.dooperation(0);
}
}

No comments:

Post a Comment