snippetjournal

– notes, snippet codes, and my journal

Tahun Kabisat Dengan JAVA

leave a comment »


import java.util.Scanner;

public class Kabisat {
private boolean bool;

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
System.out.println("tahun = ");
String string = scanner.next();

Kabisat kabisat = new Kabisat(string);
string = "bukan tahun kabisat";
if(kabisat.bool == true){
string = "tahun kabisat";
}
System.out.println(string);

}

protected Kabisat(String string){
int tahun = Integer.valueOf(string);
if(tahun % 4 == 0){
if(tahun % 100 == 0){
if(tahun % 400 == 0){
bool = true;
}else{
bool = false;
}
}else{
bool = false;
}
}else{
bool = false;
}

}
}

Written by snippetjournal

November 25, 2012 at 1:11 pm

Posted in Programming

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: