Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: None  |  size: 0.85 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package mijneerstejava;
  7.  
  8. /**
  9.  *
  10.  * @author Miauw
  11.  */
  12. public class beersong {
  13.  
  14.         public static void main (String[] args) {
  15.  
  16.         int beerNum = 99;
  17.         String word = "bottles";
  18.         while (beerNum > 0) {
  19.         if (beerNum == 1) {
  20.         word = "bottle"; // singular, as in ONE bottle.
  21.         }
  22.         System.out.println(beerNum + " " + word + " of beer on the wall");
  23.         System.out.println(beerNum + " " + word + " of beer.");
  24.         System.out.println("Take one down.");
  25.         System.out.println("Pass it around.");
  26.         beerNum = beerNum - 1;
  27.  
  28. if (beerNum > 0) {
  29.         System.out.println(beerNum + " " + word + " of beer on the wall");
  30.         } else {
  31.         System.out.println("No more bottles of beer on the wall");
  32.  
  33. } // end else
  34.         } // end while loop
  35.         } // end main method
  36.         } // end class