diff --git a/Bubblesort.java b/Bubblesort.java new file mode 100644 index 0000000..e272152 --- /dev/null +++ b/Bubblesort.java @@ -0,0 +1,34 @@ +public class Bubblesort { + + public static void main(String[] args) { + Integer howMany = args.length; + Integer[] inputs = new Integer[howMany]; + for(int i = 0; i < args.length; i++) + { + inputs[i] = Integer.parseInt(args[i]); + } + inputs = sort(inputs); + for (int i = 0; i < inputs.length; i++) + { + System.out.println(inputs[i]); + } + } + + public static Integer[] sort(Integer[] inputs) + { + for(int i = 0; i < inputs.length; i++) + { + for(int j = 0; j < inputs.length; j++) + { + if(inputs[j] > inputs[i]){ + inputs[j] += inputs[i]; + inputs[i] = inputs[j]-inputs[i]; + inputs[j] = inputs[j]-inputs[i]; + } + } + } + + return inputs; + + } +} diff --git a/Days.java b/Days.java new file mode 100644 index 0000000..51f5365 --- /dev/null +++ b/Days.java @@ -0,0 +1,68 @@ +import java.util.Scanner; + +public class Days { + + public static void main(String[] args) { + scoring(); + + } + + public static void scoring() + { + Scanner scan = new Scanner(System.in); + int year = scan.nextInt(); + int month = scan.nextInt(); + switch(month) + { + case 1: + System.out.println("This month days is 31"); + break; + case 2: + String announcedayskabisat = "this month days is 29"; + if(year%400 == 0) + { + System.out.println(announcedayskabisat); + } + else + { + if(year%4 == 0) + { + System.out.println(announcedayskabisat); + } + else + System.out.println("This month days is 28"); + } + break; + case 3: + System.out.println("This month days is 31"); + break; + case 4: + System.out.println("This month days is 30"); + break; + case 5: + System.out.println("This month days is 31"); + break; + case 6: + System.out.println("This month days is 30"); + break; + case 7: + System.out.println("This month days is 31"); + break; + case 8: + System.out.println("This month days is 30"); + break; + case 9: + System.out.println("This month days is 31"); + break; + case 10: + System.out.println("This month days is 31"); + break; + case 11: + System.out.println("This month days is 31"); + break; + case 12: + System.out.println("This month days is 31"); + break; + } + } +} diff --git a/Iteration.java b/Iteration.java new file mode 100644 index 0000000..e9e7c4a --- /dev/null +++ b/Iteration.java @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class Iteration { + + public static void main(String[] args) { + if(args.length < 1) + {} + else{ + int score = Integer.parseInt(args[0]); + System.out.println(scoring(score)); + } + + } + + public static int scoring(int score) + { + int hasilFactorial = score; + for(int i = score; i > 0; i--) + { + if(i > 1) + hasilFactorial *= (i-1); + } + return hasilFactorial; + } +} diff --git a/Months.java b/Months.java new file mode 100644 index 0000000..7617852 --- /dev/null +++ b/Months.java @@ -0,0 +1,59 @@ +import java.util.Scanner; + +public class Switch { + + public static void main(String[] args) { + if(args.length < 1) + { + System.out.println("Please input 1 - 12"); + } + else{ + int month = Integer.parseInt(args[0]); + scoring(month); + } + + } + + public static void scoring(int month) + { + switch(month) + { + case 1: + System.out.println("Month is January"); + break; + case 2: + System.out.println("Month is February"); + break; + case 3: + System.out.println("Month is March"); + break; + case 4: + System.out.println("Month is April"); + break; + case 5: + System.out.println("Month is May"); + break; + case 6: + System.out.println("Month is June"); + break; + case 7: + System.out.println("Month is July"); + break; + case 8: + System.out.println("Month is August"); + break; + case 9: + System.out.println("Month is September"); + break; + case 10: + System.out.println("Month is October"); + break; + case 11: + System.out.println("Month is November"); + break; + case 12: + System.out.println("Month is December"); + break; + } + } +} diff --git a/Recursive.java b/Recursive.java new file mode 100644 index 0000000..0990977 --- /dev/null +++ b/Recursive.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class Recursive { + + public static void main(String[] args) { + if(args.length < 1) + {} + else{ + int score = Integer.parseInt(args[0]); + int hasilFactorial = score; + System.out.println(scoring(score)); + } + + } + + public static int scoring(int score) + { + if(score > 0) + return score * scoring(score-1); + return score; + } +} diff --git a/Scoring.java b/Scoring.java new file mode 100644 index 0000000..85acda0 --- /dev/null +++ b/Scoring.java @@ -0,0 +1,38 @@ +import java.util.Scanner; + +public class Scoring { + + public static void main(String[] args) { + if(args.length < 1) + {} + else{ + int score = Integer.parseInt(args[0]); + scoring(score); + } + + } + + public static void scoring(int score) + { + if(score > 80) + { + System.out.println(" Score is A"); + } + else if(score > 60) + { + System.out.println(" Score is B"); + } + else if(score > 40) + { + System.out.println(" Score is C"); + } + else if(score > 20) + { + System.out.println(" Score is D"); + } + else + { + System.out.println(" Score is E"); + } + } +}