Forums Register Login

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

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
I've gotten help from another forum , thanks anyway guys. Figured it out.

Probably should delete this post.
+Pie Number of slices to send: Send
No, don't delete the post. Tell us what they said on the other site.
1
+Pie Number of slices to send: Send
 

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.
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 803 times.
Similar Threads
Issues with loop, input, and while
Bad sentinel loop structure for intro to java class
Using HashMap object to convert text to integer value
Object Oriented Programming confusion
For loop Pyramid Program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:30:39.