These are some logical symbols and uses of them in JAVA. I made a list of it in a program so you can easily understand its uses and functions. I also used methods under class swing for output manageability.
CODE:
import javax.swing.*;
public class Logicaloperators {
public static void main(String[] args) {
JTextArea textArea=new JTextArea (15,18);
JScrollPane scroller=new JScrollPane(textArea);
String infoSaTextArea="";
//infoSaTextArea (s) below must be a single line statement
infoSaTextArea+="Logical AND( && )"+"\nfalse && false: "+( false && false )+"\nfalse && true: "+( false && true )+"\ntrue && false: "+( true && false )+"\ntrue && true: "+( true && true );
infoSaTextArea+="\n\nLogical OR( || )"+"\nfalse || false: "+( false || false )+"\nfalse || true: "+( false || true )+"\ntrue || false: "+( true || false )+"\ntrue || true: "+( true || true );
infoSaTextArea+="\n\nBoolean Logical AND( & )"+"\nfalse & false: "+( false & false )+"\nfalse & true: "+( false & true )+"\ntrue & false: "+( true & false )+"\ntrue & true: "+( true & true );
infoSaTextArea+="\n\nBoolean Logical Inclusive OR( | )"+"\nfalse|false: "+( false | false )+"\nfalse | true: "+( false | true )+"\ntrue | false: "+( true | false )+"\ntrue | true: "+( true | true );
infoSaTextArea+="\n\nBoolean Logical Exclusive OR( ^ )"+"\nfalse ^ false: "+( false ^ false )+"\nfalse ^ true: "+( false ^ true )+"\ntrue ^ false: "+( true ^ false )+"\ntrue ^ true: "+( true ^ true );
infoSaTextArea+="\n\nLogical NOT( ! )"+"\n!false: "+(!false)+"\n!true: "+(!true);
textArea.setText(infoSaTextArea);
JOptionPane.showMessageDialog(null,scroller,"Truth Table",JOptionPane.INFORMATION_MESSAGE);
}
}
No comments:
Post a Comment