• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing Array

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Which produces:
1 thru 1
2 thru 2
3 thru 3
4 thru 4
5 thru 5
6 thru 6


I've search the wrong books or what to search on the net to figure away or how to the following output:
1 thru 10
11 thru 20
21 thru 30
31 thru 40
41 thru 50
51 thru 60


Can some one give a clue or a place to look, driving me nuts
 
Marshal
Posts: 8863
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mike,

This execise it seems has nothing to do with Arrays, at least now.

So, what kind of facts do you know?
1. You need to print out 6 lines
2. Each time, your counter is being increases by 10.
a) left hand side counter starts from 1
b) right hand side counter starts from 10

There are more than one way to solve this exercise. One way could be to use "i" only for loop iteration, and other variables you could use for printing values out. One initialize to x (number) and the other to y (number), and each iteration increment by z (number) and print out. Could you? Or you have some kind of restrictions in this exercise?

 
mike statham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No I have no restrictions on this exercise. I wrote the program last week and got 18 out of 25, miss putting a priority to the right level and this part.
I originally printed out "AA thru BB" 6 times instead of what I need now.
 
Bartender
Posts: 3323
86
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the second value first (because it's easier) what do you have to do to change 1, 2, 3 ,4 ,5 ,6 to 10, 20, 30 ,40 ,50 ,60. If you are thinking multiply by 10 then you are right. So you could simply change your print statement to

Now using the same logic what do you have to do to the first number to change 1, 2, 3 ,4 ,5 ,6 to 1, 11, 21, 31 ,41 ,51?
 
mike statham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Guess overthinking the problem was my biggest problem. I just figured it was something more complex.

Thanks for the information.


 
Liutauras Vilda
Marshal
Posts: 8863
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us mike how did you solve it. We want to see it too.
 
A berm makes a great wind break. And we all like to break wind once in a while. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic