• Post Reply Bookmark Topic Watch Topic
  • New Topic

Output question  RSS feed

 
Mario Jorge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,

I have the following code... which outputs fine like this:

1
2
3
and so on...

I need it like this
3 2 1
6 5 4
down to 200

so 200 to 1.. backwards!

Any ideas? Thanks a lot

 
Carey Brown
Bartender
Posts: 3001
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mario Jorge wrote:I need it like this
3 2 1
6 5 4
down to 200
so 200 to 1.. backwards!

It is not sufficient to just provide an example because we don't know what the rules are. You'll need to provide a description of the problem as well, such as...
  • Display the numbers from 1 to 200(not inclusive)
  • Display three numbers per line in descending order
  •  
    Mario Jorge
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hey - i need to have counter that prints out, in reverse order, every multiple of 3 between 1 and 200..
    Make sense?
     
    Carey Brown
    Bartender
    Posts: 3001
    46
    Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Mario Jorge wrote:Hey - i need to have counter that prints out, in reverse order, every multiple of 3 between 1 and 200..
    Make sense?

    You can create a for loop that increments by 3 by using i+=3.
     
    Mario Jorge
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    changed the loop section and now getting out put of

    15
    0
    0
    12
    0
    0
    9
    0
    0
    6
    0
    0
    3
    0
    0
    0

    its right to a point... the zeros need going... i know its something simples...

     
    Carey Brown
    Bartender
    Posts: 3001
    46
    Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    First off you don't need numIndex at all, you can just print the loop value directly.
    Secondly, you'll need two *nested* loops, one to count down by 3 (i-=3) and the other to count down from 3.
    Then a println that combines the two loop counter values.

     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!