logo CodeStepByStep logo

bottlesOfRootBeer

Language/Type: Java for

Write a for loop to produce the following output:

10 bottles of root beer on the wall
10 bottles of root beer
Take one down, pass it around
9 bottles of root beer on the wall

9 bottles of root beer on the wall
9 bottles of root beer
Take one down, pass it around
8 bottles of root beer on the wall

... (output continues in the same pattern) ...

1 bottles of root beer on the wall
1 bottles of root beer
Take one down, pass it around
0 bottles of root beer on the wall

(For this problem you should say "1 bottles" rather than "1 bottle" in your output, even though this is gramatically incorrect.)

Bare code: Write a fragment of Java code as described, without any class or function/method heading around your code.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.