Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started