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
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