Posted: 18 May 2020 15:17 EDT Last activity: 19 May 2020 3:15 EDT
How to loop for n amount of times? Where n is user number input?
Hi friends, quick question.
I have (pictured below) prompted user inputs, where the user can enter how many of each apparatus their process will be using. You'll notice the user has entered that there will be 3 valves. Once the user submits, I would like to ask the user questions about each of the apparatus. However, since there are 3 valves, I want to ask the user the same questions for each valve. For example, after the user submits these quantities, I want the next step to be that the user sees:
"What if Valve A is clogged?"
"What if Valve B is clogged?"
"What if Valve C is clogged?"
(A-C because the user indicated that they have 3 valves). The same is true for the tanks.
"What if Tank A overfills?"
"What if Tank B overfills?"
(A-B because the user indicated that they have 2 tanks), and so on for pumps,
"What if Pump A loses power?"
"What if Pump B loses power?"
"What if Pump C loses power?"
"What if Pump D loses power?"
(A-D because the user indicated that they have 4 pumps).
I realize I'll have to set this to be a loop, looping for n times, with n being the integer that the user input. But I don't know how to actually create this loop. I think I do it as an activity, but I don't know how to create activities. I also don't know how to label the first loop for the valve as "Valve A" and the second loop for the valve as "Valve B", and so on.
Any help would be much appreciated! Thank you in advance! :)