How to create a loop thats includes a if statement

If I understand your question correctly, every time the loop runs, you want to decrease “powerlevel” by a random value, then display a message depending on whether powerlevel can be reduced.

Here are two approaches.

1) use an if statement in your for loop

for (conditions){
    if(powerlevel cannot be decremented){
        //display a messsage
    // display a message

conditions could be iterating through all the experiments

2) use a while loop which checks whether powerlevel can be reduced in every loop

while(powerlevel can be decreased){
    //display a message containing the experiment number (starting at 1)
//display a different message 

Browse More Popular Posts

Leave a Comment