Question: (JavaScript) Im looking to add to the following code: public static void main(String[] args) { int i = 1; Random rng = new Random(); do

(JavaScript) Im looking to add to the following code:

public static void main(String[] args) { int i = 1; Random rng = new Random(); do { double randomValue = rng.nextInt(); System.out.println("CLEAN YOUR ROOM! (" + i + "x)"); } while (i < 7 && rng.nextInt() < .2);

System.out.println("THAT'S IT, YOU'RE GROUNDED!");

---------

- From here the do-while would need to be able to execute the first line until the room gets cleaned. I've been stuck and it is only printing the line once.

- Each time it prints, the chance the room gets cleaned increases by 10 (first time is 10%, second is 20%. Random has to be used to calculate the chance check and my values don't seem to be staying within the boundary because the code runs without ever stopping.

- Lastly, by the 7th time they're told to clean, a line would print saying "you're grounded"

Hopefully this updated info helps.... been stuck on this for a while now. Thanks ahead of time.

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!