• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with main structure of a program  RSS feed

 
Ray Garcia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone!

I have this program I have to write(attached). I am having problems with what the structure will look like.


The following what I have so far. The questions I have are in bold.

>get userInput of how many observations


>for(int i = 1; i <= userInput; i++)
>for(int j = 1; j <= 1; j++)
>use a switch(case) method to ask user to select an option(1,2,3)
>example, user chooses option 1:
>ask to input time
>print displacement
>ask user to stop application(Y/N)
>IF "No" is selected --------->>How do I continue with the loop if user decides to not quit? -- And do I need to put this in each 'case'?


Please feel free to chime in on other things to be aware of. Are my iterations correct?




IMG_20150329_100436.jpg
[Thumbnail for IMG_20150329_100436.jpg]
sample code and info
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ray Garcia,

Welcome to the Ranch.

You started with something similar to plain english (which is good), but you used too many technical terminology at this stage, which caused confusion, while problem itself is not fully understood.
First, try to describe everything just in plain english (for example):

1. Ask user to enter number of times he wants to observe Felix's jump
2. Display 3 options
3. Get user's choice
4. Ask user to input time in seconds
...
5. Ask users whether he wants to continue or stop
...
6. In case of continue, repeat steps 1-5 again
...

After you finish that, describe each of these steps in more details, until everything becomes clear.
Once you describe everything in your understandable language in full details, convert it to code won't be so painful.

P.S.
I'm not sure the direct answer to your "bolded" question would help you to solve this problem (do-while loop maybe does what you want?)
Once you finish with plain language steps, please post it here, so the guys could give you their observations in case you missed something.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!