Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BeerSong {
- public static void main (String[] args) {
- int beerNum = 99;
- String word = "bottles";
- while (beerNum > 0) {
- if (beerNum == 1) {
- word = " bottle "; // for when the loop ends.
- }
- System.err.println (beerNum + "" + word + " of beer on the wall");
- System.err.println (beerNum + "" + word + " of beer.");
- System.err.println ("take one down.");
- System.err.println ("pass it around.");
- beerNum = beerNum - 1;
- if (beerNum > 0) {
- System.err.println (beerNum + "" + word + " of beer on the wall");
- } else {
- System.err.println ("No more bottles of beer on the wall");
- } // end else
- } // end while loop
- } // end main method
- }// end class
Add Comment
Please, Sign In to add comment