Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago