Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training Java Future Program - Hands On By Stelli #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
30 changes: 30 additions & 0 deletions BubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public class BubbleSort{
public static void main(String[] args){

int total= args.length;
int angka[],temp;
angka= new int[100];

for(int i=0;i<total;i++){
angka[i]= Integer.parseInt(args[i]);
}

for(int i=0;i<total;i++){
for(int j=0; j<total-i-1;j++){
if(angka[j]>angka[j+1]){
temp = angka[j];
angka[j] = angka[j+1];
angka[j+1] = temp;
}
}
}

for(int i=0;i<total;i++){
System.out.println(angka[i]);
}

}
}


//kecil ke besar
23 changes: 23 additions & 0 deletions Factorial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class Factorial {
public static void main(String[] args){

if(args.length!=1){
System.out.println("Input angka!");
}

int angka= Integer.parseInt(args[0]);
int i,f=1;

for (i=1; i<=angka ; i++){
f=f*i;
}

System.out.println(f);
}
}
//
//1-20 e
//21-40 d
//41-60 c
//61-80 b
//81-100 a
30 changes: 30 additions & 0 deletions FactorialRecursive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public class FactorialRecursive {
public static void main(String[] args){

if(args.length!=1){
System.out.println("Input angka!");
}

int angka= Integer.parseInt(args[0]);
int i,f=1;

for (i=1; i<=angka ; i++){
factorial(angka);
}

System.out.println(f);
}

public static int factorial(int n){
if(n>1){
return n*(n-1);
}
return 1;
}
}
//
//1-20 e
//21-40 d
//41-60 c
//61-80 b
//81-100 a
50 changes: 50 additions & 0 deletions Month.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
public class Month {
public static void main(String[] args){

if(args.length!=2){
System.out.println("Input bulan dan tahun!");
}

int bulan= Integer.parseInt(args[0]);
int tahun= Integer.parseInt(args[1]);
switch (bulan) {
case 1 :System.out.println("Bulan Januari!");
break;
case 2 :
if(tahun%4==0 && tahun%100!=0 || year%400==0){
System.out.println("Bulan Februari punya 29 hari!");
}else{
System.out.println("Bulan Februari punya 28 hari!");
}
break;
case 3 :System.out.println("Bulan Maret!");
break;
case 4 :System.out.println("Bulan April!");
break;
case 5 :System.out.println("Bulan Mei!");
break;
case 6 :System.out.println("Bulan Juni!");
break;
case 7 :System.out.println("Bulan Juli!");
break;
case 8 :System.out.println("Bulan Agustus!");
break;
case 9 :System.out.println("Bulan September!");
break;
case 10 :System.out.println("Bulan Oktober!");
break;
case 11 :System.out.println("Bulan November!");
break;
case 12 :System.out.println("Bulan Desember!");
break;
default:System.out.println("Input Bulan!");
break;
}
}
}
//
//1-20 e
//21-40 d
//41-60 c
//61-80 b
//81-100 a
31 changes: 31 additions & 0 deletions Score.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class Score {
public static void main(String[] args){
System.out.println("Hello World !");

//KALENDAR
if(args.length!=1){
System.out.println("Input angka!");
}

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

}

}
//
//1-20 e
//21-40 d
//41-60 c
//61-80 b
//81-100 a
62 changes: 62 additions & 0 deletions TotalDays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
public class TotalDays {
public static void main(String[] args){

if(args.length!=2){
System.out.println("Input bulan dan tahun!");
}

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

switch (bulan) {
case 1: case 3: case 5: case 7: case 8 : case 10 : case 12: System.out.println("punya 31 hari!"); break;
case 4: case 6: case 9: case 11 : System.out.println("punya 30 hari!"); break;
case 2 :
if(tahun%4==0 && tahun%100!=0 || tahun%400==0){
System.out.println("punya 29 hari!");
}else{
System.out.println("punya 28 hari!");
}
}

switch (bulan) {
case 1 :System.out.println("Bulan Januari punya 30 hari!");
break;
case 2 :
if(tahun%4==0 && tahun%100!=0 || tahun%400==0){
System.out.println("Bulan Februari punya 29 hari!");
}else{
System.out.println("Bulan Februari punya 28 hari!");
}
break;
case 3 :System.out.println("Bulan Maret punya 31 hari!");
break;
case 4 :System.out.println("Bulan April punya 30 hari!");
break;
case 5 :System.out.println("Bulan Mei punya 31 hari !");
break;
case 6 :System.out.println("Bulan Juni punya 30 hari!");
break;
case 7 :System.out.println("Bulan Juli punya 31 hari!");
break;
case 8 :System.out.println("Bulan Agustus punya 31 hari!");
break;
case 9 :System.out.println("Bulan September punya 30 hari!");
break;
case 10 :System.out.println("Bulan Oktober punya 31 hari!");
break;
case 11 :System.out.println("Bulan November punya 30 hari!");
break;
case 12 :System.out.println("Bulan Desember punya 31 hari!");
break;
default:System.out.println("Input Bulan dan hari!");
break;
}
}
}
//
//1-20 e
//21-40 d
//41-60 c
//61-80 b
//81-100 a