数酒瓶童谣
作者:互联网
public class 数啤酒瓶童谣 {
public static void main(String[] args) {
int beerNum = 99;
String word = "bottles";
while (beerNum > 0) {
if (beerNum == 1) {// 等于1的时候,不数了,直接说没有
word = "bottles";
}
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 bottels of beer on the wall");
}
}
}
}
标签:酒瓶,word,System,童谣,beer,println,beerNum,out 来源: https://blog.csdn.net/Det10528/article/details/122395746