Correct the following code: | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
4 Respostas
+ 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