/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package latih1; /** * latih1 diganti dengan Name Project anda */ /** * * @author Christo Bingo <<< Bisa diganti nama anda */ public class Latih1 { /** * Latih1 diganti dengan Name Project anda */ /** * @param args the command line arguments */ public static void main(String[] args) { double A,B,C,D,E,F,G; A=10.0; B=3.0; C=A+B; D=A-B; E=A/B; F=A*B; G=A%B; System.out.println("A="+A); System.out.println("B="+B); System.out.println("C="+C); System.out.println("D="+D); System.out.println("E="+E); System.out.println("F="+F); System.out.println("G="+G); } }b. Latih Logika
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package latihlogika; /** * latihlogika diganti dengan Name Project anda */ /** * * @author Christo Bingo */ public class LatihLogika { /** * LatihLogika diganti dengan Name Project anda */ /** * @param args the command line arguments */ public static void main(String[] args) { int x=7,y=3; System.out.println(x<y && x>y); System.out.println(x>y || x>=y); System.out.println(!(x==y)); } }c. Latih Operator Relasi
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package operatorrelasi; /** * * @author Christo Bingo */ public class Operatorrelasi { /** * @param args the command line arguments */ public static void main(String[] args) { int x=7,y=3; System.out.println(x<y); System.out.println(x<=y); System.out.println(x>y); System.out.println(x>=y); System.out.println(x==y); System.out.println(x!=y); } }d. Latih Increment & Decrement
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package increment.decrement;
/**
*
* @author Christo Bingo
*/
public class IncrementDecrement {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int x=17,y=13;
System.out.println(++x);
System.out.println(x++);
System.out.println(x);
System.out.println(--y);
System.out.println(y--);
System.out.println(y);
}
}
Catatan : Untuk package diisi Name Project anda & untuk public class juga diisi dengan Name project anda7. Setelah kalian memilih salah satu dari 4 code diatas, kalian hanya tinggal me-runnya dengan cara pilih run > run project.
8. Selesai, selamat anda berhasil membuat code simpel java dengan bantuan applikasi NetBeans.
Posting Komentar Facebook Disqus