Need to write a program that will print two patterns:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
and
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 2 6
they both have to be printed in the same program and I am totaly lost
Please help
Need to write a program that will print two patterns:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
and
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 2 6
they both have to be printed in the same program and I am totaly lost
Please help
Just some simple nested loops are involved:
class Pattern
{
public static void main(String[] args)
{
for (int i=1; i<=6; i++)
{
for (int j=1; j<=i; j++)
{
System.out.print(j);
}
System.out.println("");
}
}
}
Thankyou, so much do I use the same thing to print the numbers the opposite direction also. Do I just switch around the less than signs. This is close to what I had originally . I did not have the equal signs put in correctly
thanks alot again
Just some simple nested loops are involved:
class Pattern { public static void main(String[] args) { for (int i=1; i<=6; i++) { for (int j=1; j<=i; j++) { System.out.print(j); } System.out.println(""); } } }
Here would be reversing it, making the 6 come first:
class Pattern2
{
public static void main(String[] args)
{
for (int i=6; i>=1; i--)
{
for (int j=6; j>=i; j--)
{
System.out.print(j);
}
System.out.println("");
}
}
}
If that's not what you wanted, give me some sample output.
You are absoulutely correct. My problem is I was wondering if there is a way
to include all of this in one program. SO both patterns print inside of one application. This is what I cannot figure out.
Thanks again
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
and
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 2 6
I need the program to print these exact two patterns cannot figure ou
t if it can be done in the same program
Aren't those two patterns the same? If so, just put loop in there twice:
class Pattern
{
public static void main(String[] args)
{
for (int i=1; i<=6; i++)
{
for (int j=1; j<=i; j++)
{
System.out.print(j);
}
System.out.println("");
}
System.out.println("\n\n\n\n\n");
for (int i=1; i<=6; i++)
{
for (int j=1; j<=i; j++)
{
System.out.print(j);
}
System.out.println("");
}
}
}
They are the same except for the 2nd one prints the opposite direction, a cannot figure out how to make it print the opposite way:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
and
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
but the 2 patters you are showing are the same, might help if you show us what you actually want??
I think he means this:
stupid formatting
basically, the other side of the tree (flip his image around)
Sounds like a homework problem to me.
It is. In fact it's stereotypical and handing them any code at all is doing a great disservice to the entire profession.
For anyone who does a few minutes of experimenting and reading these should be no problem at all to solve.
All I was doing was giving help. I don't think it does the entire profession a great dis-service? I mean, it's just weeding the people out that wont make it. If I supply him with some code and he turns it in, it's his problem. I've done my part of helping, and that makes me happy. I don't give a crap what he does after that. If he decides not to learn and just get help with everything, then it's his butt later on, NOT mine. That code was like 7 lines long, and I get criticized for that? I've seen people give some like a whole page long, but nothing said to them. So, if you don't like me because I'm helping someone out, don't post some message criticizing me for helping, because I'm not going to change anything I do.
It IS your butt later on. After all, he'll get a job potentially in your company where you'll then have to work with him.
If he doesn't know anything you'll be constantly correcting his mistakes and doing effectively the work of 2.
It doesn't matter if it's 7 lines or 20 pages. If it takes 7 lines to get something done 20 pages aren't needed.
NEVER give a full solution. Only give hints towards reaching a solution, or correct a statement here and there (which would require the OP to show his work what this one is incapable of because he doesn't have anything).
the key is to get them to think towards a solution without actually giving it to them.
the key is to get them to think towards a solution without actually giving it to them.
I didn't give him the full solution. If you notice I gave him the jist of it, and never gave the rest of what he wanted.
I want to print the pattern like
999999999
88888888
7777777
666666
55555
666666
7777777
88888888
999999999
3 Write a program to accept a number from command line display whether it is prime or not? Display if no value passes on command line.
Using two dimensional array in java write program to print following Pascal triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
send me the code of these
Using two dimensional array in java write program to print following Pascal triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
send me the code of these
Using two dimensional array in java write program to print following Pascal triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
We don't give away code. We help those who are willing to learn.
Start a new thread, and post what you have done so far.
And we don't work for you to order us: "send me the code of these"
HINT: Each line has the same amount of numbers
First line has 1 (one number), Second line has 1 1 (two numbers), Third line has 1 2 1 (three numbers)
Use 2 for loops one inside the other
Closing this abused zombie now.
how to print
11
12 22
13 23 33
14 24 34 44
15 25 35 45 55
1 2 3 4 5 6 7 8
1 2 3 4 5 6
1 2 3 4
1 2
by writing the code, but my suggestion:
if you have a (valid) question, not just your assignment, start a new thread. don't hijack a dead one.
i want the code for
**1
32
456
10987
1112131415
NaveenKoul:
then you should have "written" the code to get that.
and, if you couldn't, started a NEW THREAD (yes, that is both possible and allowed), show us your code, tell us what you want to do (since what you show, I don't imme"diately recognize the pattern) and where it goes wrong.
nog just assume we are jumping for joy because you have decided we are worthy to do your homework for you.
wonder what happened to the moderator who said he'd close this zombie 3 years ago. Did he die before hitting the close button?
Closed threads didn't get past the conversion to the new website.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.