diff --git a/BubbleSort.java b/BubbleSort.java new file mode 100644 index 0000000..2af66fd --- /dev/null +++ b/BubbleSort.java @@ -0,0 +1,40 @@ +import java.util.*; + +public class BubbleSort +{ + public static void main(String args[]) + { + if (args.length == 0){ + System.out.println("Usage Factorial "); + return; + } + int data[] = new int[args.length]; + int i, j; + + //Fill Data + for(i=0;i data[j]){ + temp = data[i]; + data[i] = data[j]; + data[j] = temp; + } + } + } + //FastWay + //Arrays.sort(data); + + //Print Out + System.out.println("Sorted Data:"); + for (i=0;i"); + return; + } + int mnth = Integer.parseInt(args[0]); + + switch (mnth){ + case 1: + System.out.println("Month = January"); break; + case 2: + System.out.println("Month = February"); break; + case 3: + System.out.println("Month = March"); break; + case 4: + System.out.println("Month = April"); break; + case 5: + System.out.println("Month = May"); break; + case 6: + System.out.println("Month = June"); break; + case 7: + System.out.println("Month = July"); break; + case 8: + System.out.println("Month = August"); break; + case 9: + System.out.println("Month = September"); break; + case 10: + System.out.println("Month = October"); break; + case 11: + System.out.println("Month = November"); break; + case 12: + System.out.println("Month = Desember"); break; + default: + System.out.println("Range Month are 1 - 12!"); + } + } +} \ No newline at end of file diff --git a/Calendar_2.java b/Calendar_2.java new file mode 100644 index 0000000..d795daa --- /dev/null +++ b/Calendar_2.java @@ -0,0 +1,43 @@ +import java.util.*; + +public class Calendar_2 +{ + public static void main(String args[]) + { + if (args.length != 2){ + System.out.println("Usage Calendar "); + return; + } + + int year = Integer.parseInt(args[0]); + int month = Integer.parseInt(args[1]); + int day = 0; + boolean leapy = false; + + if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){ + leapy = true; + } + + switch (month){ + case 2: + day = leapy ? 29 : 28; break; + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + day = 31; break; + case 4: + case 6: + case 9: + case 11: + day = 30; break; + default: + System.out.println("Range Month are 1 - 12!"); + + } + System.out.println("Day = " + day); + } +} \ No newline at end of file diff --git a/Factorial.java b/Factorial.java new file mode 100644 index 0000000..0a6a42f --- /dev/null +++ b/Factorial.java @@ -0,0 +1,19 @@ +import java.util.*; + +public class Factorial +{ + public static void main(String args[]) + { + if (args.length != 1){ + System.out.println("Usage Factorial "); + return; + } + int n = Integer.parseInt(args[0]); + int sum = 1; + + for(int i=2;i<=n;i++){ + sum *= i; + } + System.out.println("Sum = " + sum); + } +} diff --git a/FactorialRecurrent.java b/FactorialRecurrent.java new file mode 100644 index 0000000..ec31463 --- /dev/null +++ b/FactorialRecurrent.java @@ -0,0 +1,20 @@ +import java.util.*; + +public class FactorialRecurrent +{ + public static int fac(int x){ + if (x == 1) return 1; + return x * fac(x-1); + } + + public static void main(String args[]) + { + if (args.length != 1){ + System.out.println("Usage Factorial "); + return; + } + int n = Integer.parseInt(args[0]); + + System.out.println("Sum = " + fac(n)); + } +} diff --git a/HelloWorld.java b/HelloWorld.java new file mode 100644 index 0000000..19b3620 --- /dev/null +++ b/HelloWorld.java @@ -0,0 +1,9 @@ +import java.util.*; + +public class HelloWorld +{ + public static void main(String args[]) + { + System.out.println("Hello World!"); + } +} \ No newline at end of file diff --git a/LetterGrade.java b/LetterGrade.java new file mode 100644 index 0000000..a6988b2 --- /dev/null +++ b/LetterGrade.java @@ -0,0 +1,32 @@ +import java.util.*; + +public class LetterGrade +{ + public static void main(String args[]) + { + if (args.length != 1){ + System.out.println("Usage LetterGrade "); + return; + } + int score = Integer.parseInt(args[0]); + /* + Scanner scan = new Scanner(System.in); + + System.out.print("Score = "); + + score = scan.nextInt(); + */ + if (score > 80){ + System.out.println("Grade = A"); + } + else if (score > 70){ + System.out.println("Grade = B"); + } + else if (score > 60){ + System.out.println("Grade = C"); + } + else{ + System.out.println("Grade = D"); + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 8db2c5a..8e9b46d 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -# training-java-future-program \ No newline at end of file +# training-java-future-program + +Batch 3.0 + +@Andy Yusuf 2018 + +BliBli.Com