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
34 changes: 34 additions & 0 deletions Bubblesort.java
Original file line number Diff line number Diff line change
@@ -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;

}
}
68 changes: 68 additions & 0 deletions Days.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
25 changes: 25 additions & 0 deletions Iteration.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
59 changes: 59 additions & 0 deletions Months.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
22 changes: 22 additions & 0 deletions Recursive.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
38 changes: 38 additions & 0 deletions Scoring.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
}