This is a pattern displaying program. The pattern is
1 2 3 4 5 6
1 3 5 7 9 11
1 4 7 10 13 16
1 5 9 13 17 21
class Pat
{
int i,j,x;
public void take()
{
for(i=1;i<=4;i++)
{
x=1;
for(j=1;j<=6;j++)
{
System.out.print(" "+x);
x=x+i;
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.take();
}
}
Here is another pattern program which depends on user interaction:
if user input 1 -> {}
if user input 2 ->
{}{}
{}{}
if user input 3 ->
{}{}{}
{}{}{}
{}{}{}
import java.io.*;
class Pat1
{
int i,j,n;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void take() throws Exception
{
System.out.println("Enter '1', '2' or '3':");
n=Integer.parseInt(br.readLine());
for(i=0;i< n;i++)
{
for(j=0;j< n;j++)
{
System.out.print("{}");
}
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
Pat1 ob=new Pat1();
ob.take();
}
}
Related Post: BlueJ Programs On Pattern
1 2 3 4 5 6
1 3 5 7 9 11
1 4 7 10 13 16
1 5 9 13 17 21
class Pat
{
int i,j,x;
public void take()
{
for(i=1;i<=4;i++)
{
x=1;
for(j=1;j<=6;j++)
{
System.out.print(" "+x);
x=x+i;
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.take();
}
}
Here is another pattern program which depends on user interaction:
if user input 1 -> {}
if user input 2 ->
{}{}
{}{}
if user input 3 ->
{}{}{}
{}{}{}
{}{}{}
import java.io.*;
class Pat1
{
int i,j,n;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void take() throws Exception
{
System.out.println("Enter '1', '2' or '3':");
n=Integer.parseInt(br.readLine());
for(i=0;i< n;i++)
{
for(j=0;j< n;j++)
{
System.out.print("{}");
}
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
Pat1 ob=new Pat1();
ob.take();
}
}
Related Post: BlueJ Programs On Pattern
sir plz post some java programs on stack & queue
ReplyDeleteprinciple with their variable description &algorithm
plzzzzz help sir its urgent
I will post the program very soon, please visit the site after 2-3 days.
Delete