BlueJ program on printing the following pattern:
1 3 5 7 9
3 5 7 9 1
5 7 9 1 3
7 9 1 3 5
9 1 3 5 7
class Pattern
{
String s;
int i,j,x,y=1;
public void show()
{
System.out.println();
for(i=0;i< 5;i++)
{
x=y;
for(j=0;j< 5;j++)
{
System.out.print(x+ " ");
x=x+2;
if(x >9)
x=1;
}
System.out.println();
y=y+2;
}
}
public static void main(String args[])throws Exception
{
Pattern ob=new Pattern();
ob.show();
}
}
Related Post: BlueJ Programs On Pattern
No comments:
Post a Comment