• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Larson Lowe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I've gotten help from another forum , thanks anyway guys. Figured it out.

Probably should delete this post.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, don't delete the post. Tell us what they said on the other site.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!