casper. Powered by Blogger.

Blog ini bertujuan untuk share ilmu dan pengetahuan. Semua source/aplikasi di blog ini bebas disebar dan mencamtumkan sumber "fandy-alfa.blogspot.com".

RSS

Program Bilangan Genap Ganjil

import java.io.*;

public class ganjilgenap
{
    public static void main (String[] args) throws IOException
    {
        BufferedReader stdin =
            new BufferedReader (new InputStreamReader(System.in));
           
        System.out.println("PROGRAM MENAMPILKAN BILANGAN");
        System.out.println("        GANJIL GENAP\n");
       
        System.out.print("masukkan batas awal : ");
        int awal=Integer.parseInt(stdin.readLine());
       
        System.out.print("masukkan batas akhir : ");
        int akhir=Integer.parseInt(stdin.readLine());
       

        System.out.println("BILANGAN");
        System.out.print(" --> GANJIL : ");
       
        for(int i=awal ; i<=akhir ; i++)
        {
            if (i % 2 != 0)
            {
                System.out.print("  "+i+"  ");
            }       
        }
       
        System.out.println("");
        System.out.print(" --> GENAP  : ");
        for(int j=awal ; j<=akhir ; j++)
        {
            if (j % 2 == 0)
            {
                System.out.print("  "+j+"  ");
            }       
        }
       
        //System.out.pause;           
    }
}
  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment