nilai ganjil dan genap java

artikel ke-100…hore..hore..hore…daripada gak da yg di share apapun masuk…hehehehe…:D

//nilai ganjil dan genap..
import java.io.*;
public class GanjilOrGenap {

    public static void main(String[] args) {
		BufferedReader m = new BufferedReader(new InputStreamReader(System.in));
		String input = " ";
		int x,y;
		System.out.println("Masukkan nilai : ");
		try{
			input = m.readLine();
			}catch(IOException e){
			System.out.println(e);
			}
		x = Integer.parseInt(input);
		y = x%2;
		if(y == 0 ){
			System.out.println("Bilangan anda " + x + " adalah Genap");
			}else{
			System.out.println("Bilangan anda " + x + " adalah Ganjil");
			}
    }
}

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