Friday, June 22, 2012

BlueJ Program On Displaying Consecutive Two Even Numbers


import java.io.*;
class Enen
{
 int i,n,m,flag;
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void show() throws Exception
 {
 flag=0;
  for(i=0;i<10;i++)
  {
   System.out.println("Enter number:");
   n=Integer.parseInt(br.readLine());
   if(n%2==0)
   flag++;
   else
   flag=0;
   if(flag==1)
   m=n;
  if(flag==2)
  {
  System.out.println("Consecutive even entries="+m+"  "+n);
  flag=0;
  }
  }
  }
  public static void main(String args[])throws Exception
  {
   Enen ob=new Enen();
   ob.show();
   }
   }

Related PostBlueJ Programs on Number

2 comments:

Subscribe via email

Enter your email address:

Delivered by FeedBurner