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;
}
}
Subscribe to:
Post Comments (Atom)






0 comments:
Post a Comment