0

Correct the following code:

// classic childern's favorite"99 bottles of beer" public class BeerSong { public static void main (String[] args) { int beerNum = 99; String word = “bottles”; while (beerNum > 0) { if (beerNum == 1) { word = “bottle”; // singular, as in ONE bottle. } System.out.println(beerNum + “ ” + word + “ of beer on the wall”); System.out.println(beerNum + “ ” + word + “ of beer.”); System.out.println(“Take one down.”); System.out.println(“Pass it around.”); beerNum = beerNum - 1; if (beerNum > 0) { System.out.println(beerNum + “ ” + word + “ of beer on the wall”); } else { System.out.println(“No more bottles of beer on the wall”); } // end else } // end while loop } // end main method } // end class

19th May 2019, 7:13 AM
Vaishnavi Lokhande
Vaishnavi Lokhande - avatar
6 Respuestas
+ 7
Oh I found it! Your inverted commas!
19th May 2019, 8:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
Let me look into this. Also weird rhyme.
19th May 2019, 7:55 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
You are using special double quotes for your strings, that will fail the compiler to parse your code, because the strings aren't properly wrapped in quotes. Is this what you mean by one little flaw? P.S. Indentation is another "flaw" though 😁
19th May 2019, 7:58 AM
Ipang
+ 1
There’s still one little flaw in our code. It compiles and runs, but the output isn’t 100% perfect. See if you can spot the flaw , and fix it.
19th May 2019, 7:44 AM
Vaishnavi Lokhande
Vaishnavi Lokhande - avatar