Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions BubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class BubbleSort {
public static void main(String[] args) {

int[] input = new int[6];
int jawaban=1;

for(int a=0;a<args.length;a++){
input[a] = Integer.parseInt(args[a]);
}

for(int b=0;b<input.length;b++)
{
for(int c=0;c<input.length;c++)
{
if(input[b]<input[c])
{
int temp = input[c];
input[c]=input[b];
input[b]=temp;
}
}
}

for(int a=0;a<input.length;a++)
System.out.println(input[a]+ " ");
}

}

8 changes: 8 additions & 0 deletions HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");


}
}

13 changes: 13 additions & 0 deletions IterationFor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class IterationFor {
public static void main(String[] args) {

int input=Integer.parseInt(args[0]);
int jawaban=1;

for(int i=input;i>1;i--){
jawaban=jawaban*i;
}
System.out.println(jawaban);
}
}

63 changes: 63 additions & 0 deletions JumlahHari.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
public class JumlahHari {
public static void main(String[] args) {

if(args.length<2){
System.out.println("Usage: Calender<MonthNumber Year>");
}

int bulan= Integer.parseInt(args[0]);
int tahun= Integer.parseInt(args[1]);
int hari=1;

switch(bulan){
case 1:
hari=31;
break;
case 2:
{
if(tahun%4==0){
hari=29;
}
else
{
hari=28;
}
}
break;
case 3:
hari=31;
break;
case 4:
hari=30;
break;
case 5:
hari=31;
break;
case 6:
hari=30;
break;
case 7:
hari=31;
break;
case 8:
hari=31;
break;
case 9:
hari=30;
break;
case 10:
hari=31;
break;
case 11:
hari=30;
break;
case 12:
hari=31;
break;
}

System.out.println("Jumlah hari dalam bulan tersebut adalah " + hari);

}
}

25 changes: 25 additions & 0 deletions LetterGrade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class LetterGrade {
public static void main(String[] args) {
// System.out.println("Hello World");


int score = Integer.parseInt(args[0]);
if(score>=80){
System.out.println("A");
}
else if(score>=60)
{
System.out.println("B");
}
else if(score>=40){
System.out.println("C");
}
else if(score>=20){
System.out.println("D");
}
else{
System.out.println("E");
}
}
}

19 changes: 19 additions & 0 deletions Recursive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class Recursive {
public static void main(String[] args) {

int input=Integer.parseInt(args[0]);
int jawaban=1;

jawaban=factorial(input);

System.out.println(jawaban);
}

public static int factorial(int n){
if(n==1) return 1;
int jawab=n*(factorial(n-1));

return jawab;
}
}

53 changes: 53 additions & 0 deletions SwitchCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
public class SwitchCase {
public static void main(String[] args) {

if(args.length!=1){
System.out.println("Usage: Calender<MonthNumber>");
}

int bulan= Integer.parseInt(args[0]);

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;


}

}
}