diff --git a/bulan.java b/bulan.java new file mode 100644 index 0000000..2d0642a --- /dev/null +++ b/bulan.java @@ -0,0 +1,58 @@ +/* + * 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 blibli; + +/** + * + * @author Ghozi AW + */ +public class bulan { + + public static void main(String[] args) { + int bulan=5; + switch (bulan) { + case 1: + System.out.println("Januari"); + break; + case 2: + System.out.println("Februari"); + break; + case 3: + System.out.println("Maret"); + break; + case 4: + System.out.println("April"); + break; + case 5: + System.out.println("Mei"); + break; + case 6: + System.out.println("Juni"); + break; + case 7: + System.out.println("Juli"); + break; + case 8: + System.out.println("Agustus"); + break; + case 9: + System.out.println("September"); + break; + case 10: + System.out.println("Oktober"); + break; + case 11: + System.out.println("November"); + break; + case 12: + System.out.println("Desember"); + break; + default: + throw new AssertionError(); + } + } + +} diff --git a/faktorial.java b/faktorial.java new file mode 100644 index 0000000..8184bba --- /dev/null +++ b/faktorial.java @@ -0,0 +1,17 @@ +package blibli; + +import java.util.Scanner; + +public class faktorial { + + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + int numb=input.nextInt(); + int numtemp=1; + for (int i = 1; i <= numb; i++) { + numtemp=numtemp*(i); + System.out.println(numtemp); + } + } + +} diff --git a/faktorialrekursif.java b/faktorialrekursif.java new file mode 100644 index 0000000..902c7f1 --- /dev/null +++ b/faktorialrekursif.java @@ -0,0 +1,25 @@ +/* + * 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 blibli; + +/** + * + * @author Ghozi AW + */ +public class faktorialrekursif { + + public static void main(String[] args) { + System.out.println(rekursif(5)); + } + + static int rekursif(int angka){ + if (angka==0) { + return 1; + }else{ + return angka*rekursif(angka-1); + } + } +} diff --git a/kabisat.java b/kabisat.java new file mode 100644 index 0000000..ca8c0bf --- /dev/null +++ b/kabisat.java @@ -0,0 +1,53 @@ +/* + * 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 blibli; + +import java.util.Scanner; + +/** + * + * @author Ghozi AW + */ +public class kabisat { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.print("Bulan : "); + int bulan=input.nextInt(); + System.out.print("Tahun : "); + int tahun=input.nextInt(); + switch (bulan) { + case 2: + if ((tahun%4==0)&&(tahun%100!=0)) { + System.out.println("29"); + }else{ + System.out.println("28"); + } + break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + System.out.println("31"); + break; + case 4: + case 6: + case 9: + case 11: + System.out.println("30"); + break; + default: + throw new AssertionError(); + } + } + +} diff --git a/score.java b/score.java new file mode 100644 index 0000000..6fdc87c --- /dev/null +++ b/score.java @@ -0,0 +1,21 @@ +/* + * 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 blibli; + +import java.util.Scanner; + +/** + * + * @author Ghozi AW + */ +public class score{ + public static void main(String[] args) { + int score=100; + if (score>80) { + System.out.println("A"); + } + } +} diff --git a/sorting.java b/sorting.java new file mode 100644 index 0000000..718c0bb --- /dev/null +++ b/sorting.java @@ -0,0 +1,28 @@ +package blibli; + +import java.util.Scanner; + +public class sorting { + public static void main(String[] args) { + Scanner in=new Scanner(System.in); + System.out.print("Panjang array : "); + int panjang=in.nextInt(); + int[] array=new int[panjang]; + for (int i = 0; i 0; i--) { + for (int j = 0; j < i; j++) { + if (array[j]>array[j+1]) { + int temp=array[j]; + array[j]=array[j+1]; + array[j+1]=temp; + } + } + } + for (int i = 0; i < array.length; i++) { + System.out.println(array[i]); + } + } +}