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 Post: BlueJ Programs On Pattern
No comments:
Post a Comment