diff --git a/BubbleSort.java b/BubbleSort.java new file mode 100644 index 0000000..801797b --- /dev/null +++ b/BubbleSort.java @@ -0,0 +1,35 @@ +/* Nama File : BubbleSort.java + Nico G. S. Panjaitan +*/ + +public class BubbleSort { + + public static void main (String[] args) { + + if (args.length < 1) { + System.err.println ("Usage:Input form "); + return; + } + + int list[] = new int [args.length]; + + for (int i = 0; i < args.length; i++){ + list[i] = Integer.parseInt(args[i]); + } + + for(int i=0; i list[j]){ + int temp = list[i]; + list[i] = list[j]; + list[j] = temp; + } + } + } + + System.out.print("Hasil setelah Bubble Sort: "); + for(int i=0; i"); + return; + } + + int month = Integer.parseInt(args[0]); + switch (month) { + 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("Masukkan angka pilihan 1-12"); + + } + } + +} \ No newline at end of file diff --git a/Calender2.java b/Calender2.java new file mode 100644 index 0000000..b664c09 --- /dev/null +++ b/Calender2.java @@ -0,0 +1,50 @@ +/* Nama File : Calender2.java + Nico G. S. Panjaitan +*/ + +public class Calender2 { + public static void main (String[] args) { + + if (args.length != 2) { + System.out.println ("Usage:Month form number "); + return; + } + + int month = Integer.parseInt(args[0]); + int year = Integer.parseInt (args[1]); + + + switch (month) { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + System.out.println (31); + break; + + case 2: + if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0 )) + { + System.out.println (29); + } + else + System.out.println (28); + break; + + case 4: + case 6: + case 9: + case 11: + System.out.println (30); + break; + + default : + System.out.println("Masukkan angka pilihan 1-12"); + + } + } + +} \ No newline at end of file diff --git a/FactorRek.java b/FactorRek.java new file mode 100644 index 0000000..36bad5e --- /dev/null +++ b/FactorRek.java @@ -0,0 +1,23 @@ +/* Nama File : FactorRek.java + Nico G. S. Panjaitan +*/ + +public class FactorRek { + public static int factorial (int angka) { + if (angka == 0) + return 1; + else + return (angka * factorial(angka-1)); + } + + public static void main (String[] args) { + if (args.length != 1) { + System.out.println ("Usage:Input form "); + return; + } + + int angka = Integer.parseInt (args[0]); + + System.out.println("Factorial dari " + angka + " adalah " + factorial(angka)); + } +} \ No newline at end of file diff --git a/Factorial.java b/Factorial.java new file mode 100644 index 0000000..9607994 --- /dev/null +++ b/Factorial.java @@ -0,0 +1,20 @@ +/* Nama File : Factorial.java + Nico G. S. Panjaitan +*/ + +public class Factorial { + public static void main (String[] args) { + if (args.length != 1) { + System.out.println ("Usage: factorial form "); + return; + } + int fak = 1; + int angka = Integer.parseInt (args[0]); + + for(int i=1; i<=angka; i++){ + fak = fak * i; + } + + System.out.println("Faktorialnya "+angka+" adalah "+fak); + } +} \ No newline at end of file diff --git a/Score.java b/Score.java new file mode 100644 index 0000000..e04404f --- /dev/null +++ b/Score.java @@ -0,0 +1,34 @@ +/* Nama File : Score.java + Nico G. S. Panjaitan +*/ + +public class Score { + public static void main (String[] args) { + + if (args.length != 1) { + System.out.println ("Usage:Score form-number "); + return; + } + + int score = Integer.parseInt (args[0]); + + if( score < 30) { + System.out.println("E"); + } + else if( score < 40) { + System.out.println("D"); + } + else if( score < 50) { + System.out.println("C"); + } + else if( score < 60) { + System.out.println("B"); + } + else if( score < 70) { + System.out.println("AB"); + } + else { + System.out.println("A"); + } + } +} \ No newline at end of file