Guest User

Untitled

a guest
Feb 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2. public class BeerSong {
  3. public static void main (String[] args) {
  4. int beerNum = 99;
  5. String word = "bottles";
  6.  
  7. while (beerNum > 0) {
  8.  
  9. if (beerNum == 1) {
  10. word = " bottle "; // for when the loop ends.
  11. }
  12.  
  13. System.err.println (beerNum + "" + word + " of beer on the wall");
  14. System.err.println (beerNum + "" + word + " of beer.");
  15. System.err.println ("take one down.");
  16. System.err.println ("pass it around.");
  17. beerNum = beerNum - 1;
  18.  
  19.  
  20.  
  21. if (beerNum > 0) {
  22. System.err.println (beerNum + "" + word + " of beer on the wall");
  23. } else {
  24. System.err.println ("No more bottles of beer on the wall");
  25. } // end else
  26. } // end while loop
  27. } // end main method
  28. }// end class
Add Comment
Please, Sign In to add comment