• 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

Question about adding three asterisks to every other print line (loops)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone, been a lurker for awhile and I have a question that I'd appreciate help with.

I'm working on a program which asks to display three asterisks at the end of every 3rd line of output. So far I have the following , but I'm just confused about how to go about this.



Output:


Any hints / comments would be appreciated. Thanks!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write out on paper how you would explain to a child how to do what you want. Then revise the steps, making them simpler and simpler. Once you have that done, come back and we'll talk more.
 
Larson Lowe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I need the output to read an asterisk in every third line..

I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***

I know a modulus is needed but I can't figure it out.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Larson Lowe wrote:Basically I need the output to read an asterisk in every third line..

I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***

I know a modulus is needed but I can't figure it out.




As fred mentioned, try to do it on paper first. To figure out how to do it *and* to teach the computer how to do it, at the same time, is a skill that takes practice. Try to figure out the design first -- on paper.

Henry
 
Larson Lowe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've gotten help from another forum , thanks anyway guys. Figured it out.

Probably should delete this post.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, don't delete the post. Tell us what they said on the other site.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Larson Lowe wrote:Basically I need the output to read an asterisk in every third line..

I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***
I like to sit by the fireplace.
I like to sit by the fireplace.
I like to sit by the fireplace. ***

I know a modulus is needed but I can't figure it out.


For what it's worth, that is not what I asked you to do. That is an example of the output you want. That does not tell someone how to do it.
 
Dinner will be steamed monkey heads with a side of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic