0

Hello. I need to reproduce this pattern using one main for loop and one nested for loop. I cannot seem to figure out the right way to do this. I came close, but not close enough.
0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

for (int x = 0; x < 10; x++)
 		{
 			for (int y = 0; y < x; y++)
 			{
 				System.out.print(y);
 			}
 			System.out.println();
 		}
7
Contributors
8
Replies
9
Views
10 Years
Discussion Span
Last Post by JamesCherrill
0

I would use an array of ints. Then loop through the length of the array. Then the nested loop output the numbers from the end of the array back to the beginning using the first loop as the counter to denote how many elements need printing.

0

0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

code for this is
///

public class looping 
       {
          public static void main(String args[])
       {
          for (int x =0;  x <10; x++)
	   {
	      for (int y =x; y >=0; y--)
	   {
	      
	   	  System.out.print(y);
	   }
          System.out.println();
	   
	   }
       }
       }

/////

Edited by peter_budo: Adding code tags to old post

-1

hi i need to create a program that will count for vowel and consonant in a string

Votes + Comments
what's stopping you?
0

If you have question create new thread don't try to hijack one from 2007.
Read the notice at the top of the Java forum main page "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."
So do some work and if you get stuck start a new thread. Don't even think of starting a post with "i need to create a program..." if you don't want a torrent of sarcasm & abuse.

Edited by JamesCherrill: n/a

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.