99 Bottles of Beer on the Wall. (Java)
- September 10th, 2011
- Posted in Code
- By Lettergram
- Write comment
An exercise in creating loops and having a good time besides!
public class Classic_Print {
public static void main(String[] args) {
int beerNum = 99;
String word = "bottles";
while (beerNum > 0) {
if (beerNum == 1){
word = "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");
}}}}
Result: Should work and annoy the shit of all those around if sung.
No comments yet.