Sabtu, 09 Maret 2013


1. buatlah operator logika outputnya operasi AND,OR,XOR,NOT.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package operatorand;

/**
 *
 * @author DhoNa
 */
public class OperatorAND {



    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
            System.out.println("Operasi AND");
            boolean hasil = 10 == 10 && 100 == 100;
            System.out.println("True && True = "+ hasil);
            boolean hasil1 = 100 == 10 && 100 == 100;
            System.out.println("True && False = " +hasil1);
            boolean hasil2 = 100 == 10 && 100 == 100;
            System.out.println("False && True = " +hasil2);
            boolean hasil3 = 100 == 10 && 100 == 100;
            System.out.println("False && False = " +hasil3);
            System.out.println("\n");
            System.out.println("Operasi OR");
            boolean hasil4 = 10 == 100 || 100 == 100;
            System.out.println("True || True = "+ hasil4);
            boolean hasil5 = 10 == 100 || 100 == 100;
            System.out.println("True || False = " +hasil5);
            boolean hasil6 = 10 == 100 || 100 == 100;
            System.out.println("False || True = " +hasil6);
            boolean hasil7 = 100 == 10 || 10 == 100;
            System.out.println("False || False = " +hasil7);
            System.out.println("\n");
            System.out.println("operasi Xor");
            boolean hasil8 = 100 == 10 ^ 10==100;
            System.out.println("true ^ true=" +hasil8);
            boolean hasil9 = 100==10 ^ 100==100;
            System.out.println("true ^ false=" +hasil9);
            boolean hasil10 = 100==100 ^ 100==10;
            System.out.println("false ^ true=" +hasil10);
            boolean hasil11 = 100==100 ^ 100==100;
            System.out.println("false ^ false=" +hasil11);
            System.out.println("\n");
            System.out.println("Operasi NOT");
            boolean hasil12=false;
            System.out.println("!true = " + hasil2);
            boolean hasil13=true;
            System.out.println("!false = " + hasil13);
    }
}

0 komentar:

Posting Komentar

© Bella Yulianita 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis