diff --git a/BubbleSortAsc.java b/BubbleSortAsc.java new file mode 100644 index 0000000..822d85a --- /dev/null +++ b/BubbleSortAsc.java @@ -0,0 +1,27 @@ +import java.util.Arrays; + +public class BubbleSortAsc{ + public static void main(String[] args) { + int[] angka = new int[args.length]; + + for(int i=0;i angka[j+1]){ + //swap 2 variabel + angka[j] = angka[j]+angka[j+1]; + angka[j+1] = angka[j]-angka[j+1]; + angka[j] = angka[j]-angka[j+1]; + + //swap 3 variabel + /* int temp = angka[j]; + angka[j] = angka[j+1]; + angka[j+1] = temp;*/ + } + } + } + System.out.println("Hasil : "+Arrays.toString(angka)); + } +} \ No newline at end of file diff --git a/Days.java b/Days.java new file mode 100644 index 0000000..68d7ca7 --- /dev/null +++ b/Days.java @@ -0,0 +1,68 @@ +public class Days{ + public static void main(String[] args) { + int bln = Integer.parseInt(System.console().readLine()); + int thn = Integer.parseInt(System.console().readLine()); + switch(thn%400){ + case 0: { + switch(bln){ + case 2: System.out.println("29 hari"); break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: System.out.println("31 hari"); break; + default: System.out.println("30 hari"); break; + } + } break; + default: { + switch(thn%100){ + case 0: { + switch(bln){ + case 2: System.out.println("28 hari"); break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: System.out.println("31 hari"); break; + default: System.out.println("30 hari"); break; + } + } break; + default: { + switch(thn%4){ + case 0: { + switch(bln){ + case 2: System.out.println("29 hari"); break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: System.out.println("31 hari"); break; + default: System.out.println("30 hari"); break; + } + } break; + default : { + switch(bln){ + case 2: System.out.println("28 hari"); break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: System.out.println("31 hari"); break; + default: System.out.println("30 hari"); break; + } + }break; + } + } break; + } + } break; + } + } +} \ No newline at end of file diff --git a/Faktorial.java b/Faktorial.java new file mode 100644 index 0000000..5e756e3 --- /dev/null +++ b/Faktorial.java @@ -0,0 +1,10 @@ +public class Faktorial{ + public static void main(String[] args) { + int input = Integer.parseInt(args[0]); + int cpy = input; + for (int i=1;i=1&&input<=20){ + System.out.println("Nilai E"); + } + else if(input>=21&&input<=40){ + System.out.println("Nilai D"); + } + else if(input>=41&&input<=60){ + System.out.println("Nilai C"); + } + else if(input>=61&&input<=80){ + System.out.println("Nilai B"); + } + else if(input>=81&&input<=10){ + System.out.println("Nilai A"); + } + else{ + System.out.println("Input angka 1-100"); + } + } +} \ No newline at end of file diff --git a/Months.java b/Months.java new file mode 100644 index 0000000..8bec2bc --- /dev/null +++ b/Months.java @@ -0,0 +1,21 @@ +public class Months{ + public static void main(String[] args) { + int input = Integer.parseInt(args[0]); + // int input = Integer.parseInt(System.console().readLine()); + switch(input){ + 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: System.out.println("Input 1-12!"); break; + } + } +} \ No newline at end of file