Write rite a program for the following pattern output:
1 1
2
3 3
4 4
5 5
L=5,intersection point=2
import java.io.*;
class
IntersectionPattern
{
BufferedReader
br=new BufferedReader(new InputStreamReader(System.in));
int i,j,n,line;
public void
showPattern() throws Exception
{
System.out.println("Enter the number of rows:");
line=Integer.parseInt(br.readLine());
System.out.println("Enter the Intersection Point:");
n=Integer.parseInt(br.readLine());
for(i=1;i<=line;i++)
{
for(j=1;j<=2;j++)
{
if(j==n)
break;
System.out.print(i);
}
System.out.println();
}
}
public
static void main(String args[])throws Exception
{
IntersectionPattern ob=new IntersectionPattern();
ob.showPattern();
}
No comments:
Post a Comment