Thursday, November 19, 2015

BlueJ Program On Pattern On Numbers


To print the pattern: 
1
31
531
7531
  
Download eBook on BlueJ 

import java.io.*;
class A
{
int i,j,n,x,y;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
 public void take () throws Exception
 {
    System.out.print("\nEnter the row numbers:");
    n=Integer.parseInt(br.readLine());
    y=1;
     for( i=0;i< n;i++)
    {
    x=y;
    for(j=0;j<=i;j++)
    {
     System.out.print("    "+x);
     x=x-2;
     }
     System.out.println();
     y=y+2;
     }
     }
   public static void main(String args[]) throws Exception
   {
    A object=new A();
    object.take();
    }
    }



Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner