0

Can you people please help me in this program using only nested loops?
I cannot use bufferedreader or charAt function
Hard coding cannot be used.
The dots all stand for spaces
The pattern is:-
abcde
.bcde
..cde
...de
....e
....ed
....edc
....edcb
....edcba
The spaces are mandatory.
The dots are all spaces

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by sunny12
0

We may guide you if you post code what you made so far. Otherwise it would be handling over code to another lazy student. So show us what you got...

0

Oh I have solved the problem.
An excellent program I must say.
The code for the program is the following:

class patsp
{
public static void main()
{
int ch,i,k,l='d',m=1,n='a';
for (i=5;i>=1;i--)
{
for(k=3;k>=i-1;k--)
System.out.print(" ");
for(ch=n;ch<='e';ch++)
{
System.out.print((char)ch);
}
System.out.println();
n=n+1;
}
for (i=4;i>=1;i--)
{
for(k=m;k<=i;k++)
System.out.print(" ");
for(ch='e';ch>=l;ch--)
{
System.out.print((char)ch);
}
System.out.println();
l=l-1;
m=m-1;
}
}
}

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.