• 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

y/n loops?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello! I've got an assignment to take this code (done for a previous assignment, you insert a starting number, upper bound, and step size, and it provides a list of numbers) and put it into a loot that at the end asks you if you'd like to do it again, and entering a y starts over (obviously) and n ends the program. I have absolutely no idea how to make y continue it. I understand that something boolean would make the most sense, but I'm only about a week and a half into the course so I really have no idea other than that.( Also, it is supposed to prompt an error message if the upper bound is lower than the starting number). Here is the code:

 
Saloon Keeper
Posts: 15554
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch, Jacob!

So, you want to repeat the program while the user finishes one repetition with a "y"?
 
Jacob Smithenson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want it to complete the first run through, then prompt them with the y/n message, and then if yes it'll repeat the run through (and ask for all the info again).
 
Stephan van Hulst
Saloon Keeper
Posts: 15554
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So do you know of ways to make a certain piece of code run multiple times?
 
It was the best of times. It was the worst of times. It was a 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