Created
March 27, 2012 08:46
-
-
Save ronbeltran/2214072 to your computer and use it in GitHub Desktop.
99 Bottles of Beer in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Beer { | |
/* Prints the lyrics of "99 Bottles of Beer" */ | |
public static void lyrics(int bottles){ | |
if(bottles == 0){ | |
System.out.println(); | |
System.out.println("No bottles of beer on the wall, no bottles of beer, ya' can't take one"); | |
System.out.println("down, ya' can't pass it around, 'cause there are no more bottles of beer on the wall!"); | |
} else { | |
System.out.println(bottles + " bottles of beer on the wall," + bottles + " bottles of beer, ya' take one"); | |
System.out.println("down, ya' pass it around," + (bottles -1) + " bottles of beer on the wall."); | |
System.out.println(); | |
} | |
} | |
public static void main(String[] args){ | |
Beer beer = new Beer(); | |
for(int i = 99;i>=0;i--){ | |
beer.lyrics(i); | |
} | |
System.exit(0); | |
}//end main | |
}//end class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment