Question: i. Write a public instance method called runExperiments() which takes no argument and returns no value. The method should attempt to decrement power Level by

 i. Write a public instance method called runExperiments() which takes no

i. Write a public instance method called runExperiments() which takes no argument and returns no value. The method should attempt to decrement power Level by a random number between 1 and 3 inclusive for each experiment up to numberOfExperiments. You should make use of the supplied helper method random Integer() for this. If the power Level can be reduced, a message indicating the experiment number (starting at 1) should be displayed. If not, a suitable message should be displayed and remaining experiments should not be attempted. When all experiments have finished it should display "Experiment run stopped". Write this method, choosing a suitable kind of loop to control the number of iterations required. Hints: 1. Don't forget to make use of the return value from decrementPower(). 2. Experiments should not yet run as the default value of power Level is 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!