-1

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

Edited by pritaeas: Closed.

14
Contributors
27
Replies
53
Views
12 Years
Discussion Span
Last Post by pritaeas
Featured Replies
  • [QUOTE=mudasir rashid;1463586]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[/QUOTE] We don't give away code. We help those who are willing to learn. Start a … Read More

-1

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("");
	}
   }
}
0

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("");
	}
   }
}
-1

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.

0

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

0

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

0

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("");
	}
   }
}
0

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

0

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.

0

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.

1

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.

0

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).

0

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.

-1

I want to print the pattern like
999999999
88888888
7777777
666666
55555
666666
7777777
88888888
999999999

0

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.

-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

Votes + Comments
Cheater
2

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

0

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.

0

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.

0

wonder what happened to the moderator who said he'd close this zombie 3 years ago. Did he die before hitting the close button?