Program in BlueJ using nested loop to print the following Pattern.
-----------1234567--------
------------23456--------
-------------345----------
--------------4-----------
-------------345----------
------------23456---------
-----------1234567---------
class BlueJx
{
public void show()
{
int j,x;
for(int i=0;i< 4;i++)
{
x=1;
for(j=0;j< i;j++)
{
x++;
System.out.print(" ");
}
for(int k=i+j;k< 7;k++)
System.out.print(x++);
System.out.println();
}
for(int i=0;i< 3;i++)
{
x=1;
for(j=i;j< 2;j++)
{
x++;
System.out.print(" ");
}
for(int k=0;k< 3+i*j;k++)
System.out.print(x++);
System.out.println();
}
}
}
2017 ISC Computer Application Paper Suggestion: CLICK HERE
Program in BlueJ using nested loop to print the following Pattern.
------------1--------
-----------2_2-------
----------3_3_3------
---------4_4_4_4------
--------5_5_5_5_5-----
---------4_4_4_4------
----------3_3_3-------
-----------2_2--------
------------1----------
class BlueJx
{
public void show()
{
int j,x=1;
for(int i=1;i< =5;i++)
{
for(j=1;j< =5-i;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
if(k%2==0)
System.out.print(i);
else
System.out.print(" ");
}
System.out.println();
x=x+2;
}
for(int i=4;i >=1;i--)
{
for(j=i;j< =4;j++)
{
System.out.print(" ");
}
for(int k=0;k< =7-x;k++)
{
if(k%2==0)
System.out.print(i);
else
System.out.print(" ");
}
System.out.println();
x=x+2;
}
}
In the above program, two separate outer loops are used. For the first outer loop, again two inner loops are used. First inner loop prints the left side spaces and the second inner loop prints the values. The outer loop continues upto the line 5 5 5 5 5 5 …
With the iteration of the outer loop the iteration of the loop printing the space is decreased and iteration of the loop printing the digits is increased.
This is just the reverse for the second loop.
--------------1----------
-------------333---------
------------55555--------
-----------7777777-------
----------999999999------
-----------7777777-------
------------55555--------
-------------333---------
--------------1----------
{
public void show()
{
int j,x=1;
for(int i=1;i< =5;i++)
{
for(j=1;j< =5-i;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
System.out.print(x);
}
System.out.println();
x=x+2;
}
x=x-4;
for(int i=4;i >=1;i--)
{
for(j=i;j< =4;j++)
{
System.out.print(" ");
}
for(int k=0;k< x;k++)
{
System.out.print(x);
}
System.out.println();
x=x-2;
}
}
}
6 12
6 12 18
6 12 18 24
class BlueJx
{
public void show(int n)
{
int j,x;
for(int i=0;i< n;i++)
{
x=6;
for(j=0;j< =i;j++)
{
System.out.print(" "+x);
x=x+6;
}
System.out.println();
}
}
how to do this pattern
ReplyDelete15 14 13 12 11
10 09 08 07
06 05 04
03 02
01
class a
Delete{
void main()
{
int i,j,k=15;
for(i=5,i>=1;i--)
{
for(j=1;j<=5;j++)
{
System.out.print(k);
k--;
}
return(k);
System.out.println();
}
}
}
10987
Delete654
32
1
Please help sir
class Pattern
Delete{
public void show ()
{
int x=10;
for(int i=0;i<=3;i++)
{
for(int j=i;j<=3;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
}
I am unable to solve this programme
DeleteKindly pls help me out...
Wap in java to display the following pattern:
13579
35791
57813
79135
91357
thank you sir,
Deletemy name is G.Noothan.
public class cnms
Delete{
public static void main()
{int x=15;
for(int i = 1;i<=5;i++)
{
for(int j=5;j>=i;j--)
{
if(x<10)
{
System.out.print("0"+x+" ");
x--;
}
else
{ System.out.print(x+" ");
x--;
}
}
System.out.println();
}
}
}
class Pattern_1
Delete{
public static void main(String args[])
{
int c=15;
for(int i=5;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
System.out.print(c+" ");
c--;
}
System.out.println();
}
}
}
please solve the pattern
ReplyDelete1
3 4
5 6 7
7 8 9 10
class Pattern
ReplyDelete{
int i,j,x=15;
public void show()
{
for (i=0; i< 5;i++)
{
for(j=0; j< 5-i;j++)
{
if(x<10)
System.out.print(" 0"+x);
else
System.out.print(" "+x);
x--;
}
System.out.println();
}
}
}
class Pattern1
ReplyDelete{
int i,j,x;
public void show()
{
for(i=0;i< 4;i++)
{
x=i*2+1;
for(j=0; j< =i;j++)
{
System.out.print(" "+x);
x++;
}
System.out.println();
}
}
}
1
ReplyDelete12
123
1234
how to print this pattern?
class abc
Delete{
public static void main()
{
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
class P
ReplyDelete{
int i,j;
public void show()
{
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
--------1
ReplyDelete------1 2 1
----1 2 3 2 1
--1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
(-) are spaces.
import java.io.*;
Deleteclass Pattern
{
int i,j,k,m;
int x;
void show()
{
for(i=0;i<5;i++)
{
for(j=i*2;j<8;j++)
System.out.print(" ");
x=1;
for(k=0;k<=i;k++)
System.out.print(x+++" ");
x=x-2;
for(m=0;m<i;m++)
System.out.print(x--+" ");
System.out.println();
}
}
public static void main(String args[])
{
Pattern ob=new Pattern();
ob.show();
}
}
101010
ReplyDelete01010
1010
010
10
0
How to print this pattern ?
class Merging
Delete{
void show()
{
int i,j,x;
for(i=0;i<6;i++)
{
if(i%2==0)
x=1;
else
x=0;
for(j=i;j<6;j++)
{
System.out.print(x);
if(x>0)
x=0;
else
x=1;
}
System.out.println();
}
}
}
P
ReplyDeletePI
PIN
PINK
PINKU
How to print this pattern?
class Enen
Delete{
int i,j,len;
public void show(String s)
{
len=s.length();
for(i=0;i<len;i++)
{
for(j=0;j<=i;j++)
System.out.print(s.charAt(j));
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Enen ob=new Enen();
ob.show("PINKU");
}
}
Sir,
ReplyDeleteCan u solve the pattern
A
B C
D E F
G H I J
K L M N O
class Enen
Delete{
int n=65,i,j;
public void take()
{
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print((char)n);
n++;
}
System.out.println();
}
}
public static void main(String args[])
{
Enen ob=new Enen();
ob.take();
}
}
how to do this:
ReplyDelete12345
22345
33345
44445
55555
class P
Delete{
int i,j,x;
public void show()
{
for(i=1;i<=5;i++)
{
x=i;
for(j=1;j<=5;j++)
{
System.out.print(x);
if(j>=x)
x++;
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
P ob=new P();
ob.show();
}
}
sir please explain me the concept of pattern printing in such a way so that i can be able to apply it for any type of pattern by myself....
ReplyDeleteThere is no such short cut process. Go through different pattern programs, try to understand the logic and and one day you will be able to develop your own logic.
Deletehow to make an alphabet pattern
ReplyDeletePlease specify the pattern.
DeleteSir can you please give the program for the following pattern-
ReplyDelete1
2 4
1 3 5
2 4 6 8
1 3 5 7 9 for n=5
#include
Deletevoid main()
{
int i,j,x,n;
char ch;
printf("Enter the no of rows: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
if(i%2==0)
x=1;
else
x=2;
for(j=0;j<=i;j++)
{
printf("%d",x);
x=x+2;
}
printf("\n");
}
getch();
}
Mr. Dhananjoy, you seem to be very good in programming...Can u tell me d simple logic or how do i understand what to do when a pattern program is given..
ReplyDeleteGo through lots of pattern programs and try to find out the logic behind those programs. This will help you to develop your own logic.
Delete54321
ReplyDelete5432
543
54
5
class pattern
Delete{
public static void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
System.out.print(j);
System.out.println();
}
}
}
Can somebody help me understanding funtion oveloading in bluej and methods
ReplyDeletePlease check with 'function overloading' in the site and you will get related posts.
DeleteHow to write this program :
ReplyDelete1
10
101
1010
1010
class A
Delete{
void show()
{
int i,j,x;
for(i=0;i<5;i++)
{
x=1;
for(j=0;j<=i;j++)
{
System.out.print(x);
if(x>0)
x=x-1;
else
x=x+1;
}
System.out.println();
}
}
}
Mr. Dhananjoy Sir, can you solve the following pattern....
ReplyDelete123454321
1234 4321
123 321
12 21
1 1
This comment has been removed by the author.
DeleteI think this program is already posted still here are the codes:
Deleteclass pt1
{
int i,j,k,m,x;
void show()
{
for(i=0;i< 5;i++)
{
x=1;
for(j=i;j< 5;j++)
System.out.print(x++);
for(k=0;k< i; k++)
System.out.print(" ");
x=x-1;
for(m=i;m< 5;m++)
System.out.print(x--);
System.out.println();
}
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
hello sir....can u solve the following pattern (nested for):-
ReplyDelete1
!
12
!
123
!
1234
!
thank you in advance :D
I will post it very soon
DeleteWhen will you post?Its been two years since you haven't posted for this pattern... # Dhananjoy Chakraborty
DeleteThanks for reminder.
DeleteI want program for this pattern
ReplyDelete#
##
###
####
#####
####
###
##
#
class Pat
Delete{
void showPattern()
{
int i,j,x=0;
for(i=0;i<7;i++)
{
if(i<=7/2)
x++;
else
x--;
for(j=0;j<x;j++)
{
System.out.print("#");
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.showPattern();
}
}
WRITE A PROGRAM FOR THE FOLLOWING PATTERN-
ReplyDeleteOUTPUT:
1 1
2
3 3
4 4
5 5
L=5,INTERSECTIONPOINT=2
Posted on 27 May 2014, please check.
DeleteWAP TO ACCEPT THE LOWER RANGE AND UPPER RANGE FROM THE USER AND DISPLAY THE PRIME PALINDROME NUMBER IN THAT RANGE-METHODS BOOLEAN IS PRIME()
ReplyDeleteBOOLEAN IS PALINDROME()
VOID GENERATE()
MAIN()
Posted on 27 May 2014, please check
DeleteWRITE A PROGRAM FOR THE FOLLOWING PATTERN-
ReplyDeleteOUTPUT:
-------1----1--------
----------2----------
---------3-----3-------
------4----------4-----
---5---------------5----
L=5,INTERSECTIONPOINT=2
1
ReplyDelete12
123
1234
12345
123456
class P
Delete{
public void showPattern()
{
for(int i=1;i<=6;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
wap to accept a word and check wether the word is palindrome or not?
ReplyDeleterespected sir plz help
This program already exists in my site, anyway I am again posting here.
Deleteimport java.io.*;
class PalindromeChecking
{
int i,len,x;
String str;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void check() throws Exception
{
System.out.println("Enter the Word:");
str=br.readLine();
len=str.length();
x=len-1;
for(i=0;i<len/2;i++)
{
if(str.charAt(i)!=str.charAt(x--))
break;
}
if(i<len/2)
System.out.println("The word is not palindrome.");
else
System.out.println("The word is palindrome.");
}
public static void main(String args[])throws Exception
{
PalindromeChecking ob=new PalindromeChecking();
ob.check();
}
}
Wrap in java to display the area and perimeter of a circle rectangular square using the concept of function overloading .accept the length , breath,side and radius using input statement
ReplyDeleteSir please help with wap to display
ReplyDelete1
2 2
3 3 3
4 4 4 4
n n n n n
4 4 4 4
3 3 3
2 2
1
import java.io.*;
Deleteclass prg
{
public static void main()throws IOException
{
System.out.println("enter a number");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
int n=Integer.parseInt(s);
int x=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(x);
}
System.out.println();
x++;
}
int y=n-1;
for(int i=1;i<=n-1;i++)
{
for(int j=1;j<=n-i;j++)
{
System.out.print(y);
}
System.out.println();
y--;
}
}
}
import java.io.*;
Deleteclass prg
{
public static void main()throws IOException
{
System.out.println("enter a number");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
int n=Integer.parseInt(s);
int x=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(x);
}
System.out.println();
x++;
}
int y=n-1;
for(int i=1;i<=n-1;i++)
{
for(int j=1;j<=n-i;j++)
{
System.out.print(y);
}
System.out.println();
y--;
}
}
}
please help me to print this
ReplyDelete1
121
12321
1234321
123454321
1234321
12321
121
1
Posted today
DeleteI want to print this. Please help me sir(- are spaces)
ReplyDelete*------------*
--*--------*
----*----*
------ *
----*-----*
--*---------*
*-------------*
class xprg
Delete{
public static void printCross()
{
int size=5;
char display='*';
for (int row = 0; row < size; row++) {
for (int col = 0; col < size; col++) {
if (row == col || row + col == size - 1) {
System.out.print(display);
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
Please help, how to print the following pattern in bluej using nested loops
ReplyDelete*
* *
* * *
* * * *
* * *
* *
*
class pattern
Delete{
static void main()
{
for (int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
for(int k=3;k>=1;k--)
{
for(int l=1;l<=k;l++)
{
System.out.print("*");
}
System.out.println();
}
}
}
Please help.
ReplyDelete1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
class P
Delete{
int i,j,x=1;
void show()
{
i=1;
for(;;)
{
for(j=0;j< i;j++)
{
System.out.print(x++);
}
if(x==15)
break;
i++;
}
}
}
hOW TO MAKE THIS PATTERN IN STRING?
DeleteJ
EE
UUU
LLLL
BBBB
Please check the post on 25 October 2014
Delete* * * * *
ReplyDelete* * * *
* * *
* *
*
how to print the above program..????????????
class String1
Delete{
int i,j;
public void showPattern()throws Exception
{
for(i=4;i >0;i--)
{
for(j=i;j >0;j--)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
String1 ob=new String1();
ob.showPattern();
}
}
class pattern
Delete{
public static void main(String args[])
{
int i,j;
for(i=1;i<=4;i--)
{
for(j=1;j<=i;j++)
System.out.print("*");
System.out.println();
}
}
}
wap to input a sentence and print the word containing maximum numbers of vowels.
ReplyDeleteS/I: HAPPY NEW YEAR
O/P:YEAR
Posted today...
Delete1 3 5 7 9
ReplyDelete3 5 7 9 1
5 7 9 1 3
7 9 1 3 5
9 1 3 5 7
Posted today
Delete55555
ReplyDelete54444
54333
54322
54321
Check today's post
DeleteWrite a bluej Java program to print the following
ReplyDelete1234*
123*5
12*45
1*345
*2345
posted today. pl. cleck
Deletesir please tell this pattern
ReplyDelete*
**
***
****
*****
******
I am writing the loop only, complete the program yourself:
Deletefor( int i=0;i<=6;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
sir, how to print these two patterns? Please show me their codings-
ReplyDeletee
ed
edc
edcb
edcba
and
a c e g
i k m
o q
s
Programs posted on 29 March 2015.
Deletesir, how to print these patterns? Please show me it codings-
ReplyDelete*
*#
*#*
*#*#
*#*#*
import java.io.*;
Deleteclass A
{
int i,j;
public void show ()
{
for(i=0;i< 5;i++)
{
for(j=0;j<=i;j++)
{
if(j%2==0)
System.out.print("*");
else
System.out.print("#");
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
A ob=new A();
ob.show();
}
}
sir, can you please send me the program for these patters
ReplyDelete54321
5432
543
54
5
1
12
123
1234
12345
* * * *
* * *
* * * *
* * *
* * * *
* * *
* * * *
54321
Delete5432
543
54
5
1
12
123
1234
12345
class A
{
int i,j,col=5, x=5,val;
public void take ()
{
for( i=0;i<11;i++)
{
for(j=0;j<x;j++)
{
System.out.print(" "+col);
if(i<=11/2)
col--;
else
col++;
}
System.out.println();
if(i<11/2)
{
x--;
col=5;
}
else
{
x++;
col=1;
}
}
}
public static void main(String args[])
{
A object=new A();
object.take();
}
}
* * * *
* * *
* * * *
* * *
* * * *
* * *
* * * *
class A
{
int i,j,x;
public void take ()
{
for( i=0;i<7;i++)
{
if(i%2==0)
x=4;
else
x=3;
for(j=0;j<x;j++)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String args[])
{
A object=new A();
object.take();
}
}
......E
ReplyDelete.....TE
....UTE
...PUTE
..MPUTE
.OMPUTE
COMPUTE
class Bill
Delete{
String s="COMPUTE";
int i,j,k,len;
void show()
{
len=s.length();
for(i=len-1;i>=0;i--)
{
for(j=i;j>=0;j--)
System.out.print(" ");
for(k=i;k<=len-1;k++)
System.out.print(s.charAt(k));
System.out.println();
}
}
public static void main(String args[])
{
Bill ob=new Bill();
ob.show();
}
}
Sir this one plzzz:-
ReplyDelete1234567
12345
123
1
class Bill
Delete{
int i,j,k,x=6;
void show()
{
for(i=0;i<=3;i++)
{
k=1;
for(j=0;j<=x;j++)
System.out.print(k++);
System.out.println();
x=x-2;
}
}
public static void main(String args[])
{
Bill ob=new Bill();
ob.show();
}
}
please solve this pattern
ReplyDelete1
22
333
4444
please solve this pattern
ReplyDelete1
2 2
3 3 3
4 4 4 4
class Bill
Delete{
int i,j;
void show()
{
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
System.out.print(i+ " ");
System.out.println();
}
}
public static void main(String args[])
{
Bill ob=new Bill();
ob.show();
}
}
how print this pattern
ReplyDelete1a
1a 2b
1a 2b 3c
1a 2b 3c 4d
Pl. check post on 8 January 2016.
DeletePl. check post on 8 January 2016.
DeleteB L U E J
ReplyDeleteL U E J B
U E J B L
E J B L U
J B L U E
please tell me how to print this pattern
Program posted todays
Deletesir i needed guidance in fibonacci series
ReplyDeleteSearch with the word fibonacci in my site.
Delete55555
ReplyDelete4444
333
22
1
class Pat
Delete{
int i,j;
void showPattern()
{
for(i=5;i>=1;i--)
{
for(j=i;j>=1;j--)
{
System.out.print(i);
}
System.out.println();
}
}
}
1
ReplyDelete1 1
1 1 2
1 1 2 3 (for n lines)
Thanks in advance
follow the site and I'll post the solution very soon.
Deleteplease help me with this!!!!!
ReplyDelete1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
sir please solve this pattern:
ReplyDelete............C.....
...........CO.....
..........COM.....
........ COMP.....
........COMPU.....
.......COMPUT.....
......COMPUTE.....
.....COMPUTER.....
class Pat
Delete{
String s="COMPUTER";
int i,j,k,len;
public void show()
{
len=s.length();
for(i=0;i<=len-1;i++)
{
for(j=i;j<=len-2;j++)
System.out.print(" ");
for(k=0;k<=i;k++)
System.out.print(s.charAt(k));
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Very beneficial and knowledgeable ..Thank u so much SIR CHAKROBORTY.SIR could u guide me in understanding array related programs that would be beneficial 4 me in my ICSE 10TH Exam 2017
ReplyDeleteWelcome
Delete123454321
ReplyDelete1234 4321
123 321
12 21
1 1
class pt1
Delete{
int i,j,k,m,x;
void show()
{
for(i=0;i<5;i++)
{
x=1;
for(j=i;j<5;j++)
System.out.print(x++);
for(k=0;k<i; k++)
System.out.print(" ");
x=x-1;
for(m=i;m<5;m++)
System.out.print(x--);
System.out.println();
}
}
public static void main(String args[])
{
pt1 ob=new pt1();
ob.show();
}
}
Plz do this program pattern
ReplyDelete1
1_2
1_2_3
1_2_3_4
1_2_3_4_5
_ stands for space
Posted on 24 May 2017
Deletecan anyone help me
ReplyDelete9
9 7
9 7 5
9 7 5 3
9 7 5 3 1
class P
Delete{
int i,j,x;
public void display()
{
for(i=0;i<=4;i++)
{
x=9;
for(j=0;j<=i;j++)
{
System.out.print(x);
x=x-2;
}
System.out.println();
}
}
}
please help with this one
ReplyDelete1
3 1
5 3 1
7 5 3 1
9 7 5 3 1
Please check the latest post
Delete#
ReplyDelete# #
# # #
# # # #
Through scanner method pls sir
You have fixed number of rows and columns in the pattern, why do you need Scanner class for this program?
DeleteSir please this program:
ReplyDeleteL
AL
IAL
RIAL
TRIAL
class P
Delete{
int i,j;
String str="TRIAL";
int len;
public void show()
{
len=str.length()-1;
for(i=len;i>=0;i--)
{
for(j=i;j<=len;j++)
{
System.out.print(str.charAt(j));
}
System.out.println();
}
}
public static void main(String args[])
{
P ob=new P();
ob.show();
}
}
Plz help me withthis one
ReplyDelete333
22
1
class A
Delete{
public void show()
{
for(int i=3;i>=1;i--)
{
for(int j=i;j>=1;j--)
{
System.out.print(i);
}
System.out.println();
}
}
public static void main(String args[])
{
A ob=new A();
ob.show();
}
}
9
ReplyDelete79
579
3579
13579
Please help me to write the code
Please check post on 11/11/2018
DeleteI want this answer
ReplyDelete0
1 1
2 3 5
8 13 21 34