Search This Blog

Loading...

Monday, July 28, 2014

BlueJ Programs on intersection and number of lines


In this BlueJ program, user will enter intersection point and number of lines and the pattern will be displayed.

Sample input and output


Enter the intersection point: 4
Enter the number of lines: 7

Output
11
22
33
4
55
66
77


import java.io.*;
class patterns
{
public void disp()throws Exception
{
BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter intersection point");
int p=Integer.parseInt(r.readLine());
System.out.println("Enter number of lines");
int l=Integer.parseInt(r.readLine());
for(int i=1;i<=l;i++)
{
for(int j=1;j<=2;j++)
{
System.out.print(i);
if(i==p)
break;
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
new patterns().disp();
}
}

CHECK HERE FOR PREVIOUS POSTS

Google+ Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner