/* * boolean_gates.java * * Created on 23 Οκτώβριος 2012, 8:38 πμ * * The purpose of this program is to similate the function of an XOR gate * using the decision making construct if .. else and simple integer inputs * of 0 and 1. * */ ; /** * * @author Harris */ import java.io.*; public class boolean_gates { String data; int a, b, xor; /** Creates a new instance of boolean_gates */ public boolean_gates() throws IOException { input(); xor_process(); formated_table(); } public void input()throws IOException { InputStreamReader inStream=new InputStreamReader(System.in); BufferedReader stdin=new BufferedReader(inStream); //boolean wrong; //do{ //try{ //wrong = false; System.out.print("Input A: "); data = stdin.readLine(); a = Integer.parseInt(data); System.out.print("Input B: "); data = stdin.readLine(); b = Integer.parseInt(data); //} //catch (Exception e) //{System.out.println("wrong data type " + e.toString()); // wrong = true; //} //} while (wrong==true); } public void xor_process(){ if (((a==0) && (b==1)) || ((a==1) && (b==0))) xor = 1; else xor = 0; } public void formated_table(){ System.out.println ("A xor B = " + xor); } public static void main(String[] args) throws IOException { new boolean_gates(); } }