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

Ghz-Java #8

Open
wants to merge 2 commits 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
58 changes: 58 additions & 0 deletions bulan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package blibli;

/**
*
* @author Ghozi AW
*/
public class bulan {

public static void main(String[] args) {
int bulan=5;
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;
default:
throw new AssertionError();
}
}

}
17 changes: 17 additions & 0 deletions faktorial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package blibli;

import java.util.Scanner;

public class faktorial {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int numb=input.nextInt();
int numtemp=1;
for (int i = 1; i <= numb; i++) {
numtemp=numtemp*(i);
System.out.println(numtemp);
}
}

}
25 changes: 25 additions & 0 deletions faktorialrekursif.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package blibli;

/**
*
* @author Ghozi AW
*/
public class faktorialrekursif {

public static void main(String[] args) {
System.out.println(rekursif(5));
}

static int rekursif(int angka){
if (angka==0) {
return 1;
}else{
return angka*rekursif(angka-1);
}
}
}
53 changes: 53 additions & 0 deletions kabisat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package blibli;

import java.util.Scanner;

/**
*
* @author Ghozi AW
*/
public class kabisat {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.print("Bulan : ");
int bulan=input.nextInt();
System.out.print("Tahun : ");
int tahun=input.nextInt();
switch (bulan) {
case 2:
if ((tahun%4==0)&&(tahun%100!=0)) {
System.out.println("29");
}else{
System.out.println("28");
}
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.println("31");
break;
case 4:
case 6:
case 9:
case 11:
System.out.println("30");
break;
default:
throw new AssertionError();
}
}

}
21 changes: 21 additions & 0 deletions score.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package blibli;

import java.util.Scanner;

/**
*
* @author Ghozi AW
*/
public class score{
public static void main(String[] args) {
int score=100;
if (score>80) {
System.out.println("A");
}
}
}
28 changes: 28 additions & 0 deletions sorting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package blibli;

import java.util.Scanner;

public class sorting {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.print("Panjang array : ");
int panjang=in.nextInt();
int[] array=new int[panjang];
for (int i = 0; i <array.length; i++) {
System.out.print("Nilai ke-"+i+" : ");
array[i]=in.nextInt();
}
for (int i = array.length-1; i >0; i--) {
for (int j = 0; j < i; j++) {
if (array[j]>array[j+1]) {
int temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}