数酒瓶

public class BeerSong {
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");
}
}
}
}

输出:

99 bottlesof beer on the wall
99 bottlesof beer.
Take one down.
pass it around.
98 bottlesof beer on the wall
98 bottlesof beer on the wall
98 bottlesof beer.
Take one down.
pass it around.
97 bottlesof beer on the wall
97 bottlesof beer on the wall
97 bottlesof beer.
Take one down.
pass it around.
96 bottlesof beer on the wall
96 bottlesof beer on the wall
96 bottlesof beer.
Take one down.
pass it around.
95 bottlesof beer on the wall
95 bottlesof beer on the wall
95 bottlesof beer.
Take one down.
pass it around.
94 bottlesof beer on the wall
94 bottlesof beer on the wall
94 bottlesof beer.
Take one down.
pass it around.
93 bottlesof beer on the wall
93 bottlesof beer on the wall
93 bottlesof beer.
Take one down.
pass it around.
92 bottlesof beer on the wall
92 bottlesof beer on the wall
92 bottlesof beer.
Take one down.
pass it around.
91 bottlesof beer on the wall
91 bottlesof beer on the wall
91 bottlesof beer.
Take one down.
pass it around.
90 bottlesof beer on the wall
90 bottlesof beer on the wall
90 bottlesof beer.
Take one down.
pass it around.
89 bottlesof beer on the wall
89 bottlesof beer on the wall
89 bottlesof beer.
Take one down.
pass it around.
88 bottlesof beer on the wall
88 bottlesof beer on the wall
88 bottlesof beer.
Take one down.
pass it around.
87 bottlesof beer on the wall
87 bottlesof beer on the wall
87 bottlesof beer.
Take one down.
pass it around.
86 bottlesof beer on the wall
86 bottlesof beer on the wall
86 bottlesof beer.
Take one down.
pass it around.
85 bottlesof beer on the wall
85 bottlesof beer on the wall
85 bottlesof beer.
Take one down.
pass it around.
84 bottlesof beer on the wall
84 bottlesof beer on the wall
84 bottlesof beer.
Take one down.
pass it around.
83 bottlesof beer on the wall
83 bottlesof beer on the wall
83 bottlesof beer.
Take one down.
pass it around.
82 bottlesof beer on the wall
82 bottlesof beer on the wall
82 bottlesof beer.
Take one down.
pass it around.
81 bottlesof beer on the wall
81 bottlesof beer on the wall
81 bottlesof beer.
Take one down.
pass it around.
80 bottlesof beer on the wall
80 bottlesof beer on the wall
80 bottlesof beer.
Take one down.
pass it around.
79 bottlesof beer on the wall
79 bottlesof beer on the wall
79 bottlesof beer.
Take one down.
pass it around.
78 bottlesof beer on the wall
78 bottlesof beer on the wall
78 bottlesof beer.
Take one down.
pass it around.
77 bottlesof beer on the wall
77 bottlesof beer on the wall
77 bottlesof beer.
Take one down.
pass it around.
76 bottlesof beer on the wall
76 bottlesof beer on the wall
76 bottlesof beer.
Take one down.
pass it around.
75 bottlesof beer on the wall
75 bottlesof beer on the wall
75 bottlesof beer.
Take one down.
pass it around.
74 bottlesof beer on the wall
74 bottlesof beer on the wall
74 bottlesof beer.
Take one down.
pass it around.
73 bottlesof beer on the wall
73 bottlesof beer on the wall
73 bottlesof beer.
Take one down.
pass it around.
72 bottlesof beer on the wall
72 bottlesof beer on the wall
72 bottlesof beer.
Take one down.
pass it around.
71 bottlesof beer on the wall
71 bottlesof beer on the wall
71 bottlesof beer.
Take one down.
pass it around.
70 bottlesof beer on the wall
70 bottlesof beer on the wall
70 bottlesof beer.
Take one down.
pass it around.
69 bottlesof beer on the wall
69 bottlesof beer on the wall
69 bottlesof beer.
Take one down.
pass it around.
68 bottlesof beer on the wall
68 bottlesof beer on the wall
68 bottlesof beer.
Take one down.
pass it around.
67 bottlesof beer on the wall
67 bottlesof beer on the wall
67 bottlesof beer.
Take one down.
pass it around.
66 bottlesof beer on the wall
66 bottlesof beer on the wall
66 bottlesof beer.
Take one down.
pass it around.
65 bottlesof beer on the wall
65 bottlesof beer on the wall
65 bottlesof beer.
Take one down.
pass it around.
64 bottlesof beer on the wall
64 bottlesof beer on the wall
64 bottlesof beer.
Take one down.
pass it around.
63 bottlesof beer on the wall
63 bottlesof beer on the wall
63 bottlesof beer.
Take one down.
pass it around.
62 bottlesof beer on the wall
62 bottlesof beer on the wall
62 bottlesof beer.
Take one down.
pass it around.
61 bottlesof beer on the wall
61 bottlesof beer on the wall
61 bottlesof beer.
Take one down.
pass it around.
60 bottlesof beer on the wall
60 bottlesof beer on the wall
60 bottlesof beer.
Take one down.
pass it around.
59 bottlesof beer on the wall
59 bottlesof beer on the wall
59 bottlesof beer.
Take one down.
pass it around.
58 bottlesof beer on the wall
58 bottlesof beer on the wall
58 bottlesof beer.
Take one down.
pass it around.
57 bottlesof beer on the wall
57 bottlesof beer on the wall
57 bottlesof beer.
Take one down.
pass it around.
56 bottlesof beer on the wall
56 bottlesof beer on the wall
56 bottlesof beer.
Take one down.
pass it around.
55 bottlesof beer on the wall
55 bottlesof beer on the wall
55 bottlesof beer.
Take one down.
pass it around.
54 bottlesof beer on the wall
54 bottlesof beer on the wall
54 bottlesof beer.
Take one down.
pass it around.
53 bottlesof beer on the wall
53 bottlesof beer on the wall
53 bottlesof beer.
Take one down.
pass it around.
52 bottlesof beer on the wall
52 bottlesof beer on the wall
52 bottlesof beer.
Take one down.
pass it around.
51 bottlesof beer on the wall
51 bottlesof beer on the wall
51 bottlesof beer.
Take one down.
pass it around.
50 bottlesof beer on the wall
50 bottlesof beer on the wall
50 bottlesof beer.
Take one down.
pass it around.
49 bottlesof beer on the wall
49 bottlesof beer on the wall
49 bottlesof beer.
Take one down.
pass it around.
48 bottlesof beer on the wall
48 bottlesof beer on the wall
48 bottlesof beer.
Take one down.
pass it around.
47 bottlesof beer on the wall
47 bottlesof beer on the wall
47 bottlesof beer.
Take one down.
pass it around.
46 bottlesof beer on the wall
46 bottlesof beer on the wall
46 bottlesof beer.
Take one down.
pass it around.
45 bottlesof beer on the wall
45 bottlesof beer on the wall
45 bottlesof beer.
Take one down.
pass it around.
44 bottlesof beer on the wall
44 bottlesof beer on the wall
44 bottlesof beer.
Take one down.
pass it around.
43 bottlesof beer on the wall
43 bottlesof beer on the wall
43 bottlesof beer.
Take one down.
pass it around.
42 bottlesof beer on the wall
42 bottlesof beer on the wall
42 bottlesof beer.
Take one down.
pass it around.
41 bottlesof beer on the wall
41 bottlesof beer on the wall
41 bottlesof beer.
Take one down.
pass it around.
40 bottlesof beer on the wall
40 bottlesof beer on the wall
40 bottlesof beer.
Take one down.
pass it around.
39 bottlesof beer on the wall
39 bottlesof beer on the wall
39 bottlesof beer.
Take one down.
pass it around.
38 bottlesof beer on the wall
38 bottlesof beer on the wall
38 bottlesof beer.
Take one down.
pass it around.
37 bottlesof beer on the wall
37 bottlesof beer on the wall
37 bottlesof beer.
Take one down.
pass it around.
36 bottlesof beer on the wall
36 bottlesof beer on the wall
36 bottlesof beer.
Take one down.
pass it around.
35 bottlesof beer on the wall
35 bottlesof beer on the wall
35 bottlesof beer.
Take one down.
pass it around.
34 bottlesof beer on the wall
34 bottlesof beer on the wall
34 bottlesof beer.
Take one down.
pass it around.
33 bottlesof beer on the wall
33 bottlesof beer on the wall
33 bottlesof beer.
Take one down.
pass it around.
32 bottlesof beer on the wall
32 bottlesof beer on the wall
32 bottlesof beer.
Take one down.
pass it around.
31 bottlesof beer on the wall
31 bottlesof beer on the wall
31 bottlesof beer.
Take one down.
pass it around.
30 bottlesof beer on the wall
30 bottlesof beer on the wall
30 bottlesof beer.
Take one down.
pass it around.
29 bottlesof beer on the wall
29 bottlesof beer on the wall
29 bottlesof beer.
Take one down.
pass it around.
28 bottlesof beer on the wall
28 bottlesof beer on the wall
28 bottlesof beer.
Take one down.
pass it around.
27 bottlesof beer on the wall
27 bottlesof beer on the wall
27 bottlesof beer.
Take one down.
pass it around.
26 bottlesof beer on the wall
26 bottlesof beer on the wall
26 bottlesof beer.
Take one down.
pass it around.
25 bottlesof beer on the wall
25 bottlesof beer on the wall
25 bottlesof beer.
Take one down.
pass it around.
24 bottlesof beer on the wall
24 bottlesof beer on the wall
24 bottlesof beer.
Take one down.
pass it around.
23 bottlesof beer on the wall
23 bottlesof beer on the wall
23 bottlesof beer.
Take one down.
pass it around.
22 bottlesof beer on the wall
22 bottlesof beer on the wall
22 bottlesof beer.
Take one down.
pass it around.
21 bottlesof beer on the wall
21 bottlesof beer on the wall
21 bottlesof beer.
Take one down.
pass it around.
20 bottlesof beer on the wall
20 bottlesof beer on the wall
20 bottlesof beer.
Take one down.
pass it around.
19 bottlesof beer on the wall
19 bottlesof beer on the wall
19 bottlesof beer.
Take one down.
pass it around.
18 bottlesof beer on the wall
18 bottlesof beer on the wall
18 bottlesof beer.
Take one down.
pass it around.
17 bottlesof beer on the wall
17 bottlesof beer on the wall
17 bottlesof beer.
Take one down.
pass it around.
16 bottlesof beer on the wall
16 bottlesof beer on the wall
16 bottlesof beer.
Take one down.
pass it around.
15 bottlesof beer on the wall
15 bottlesof beer on the wall
15 bottlesof beer.
Take one down.
pass it around.
14 bottlesof beer on the wall
14 bottlesof beer on the wall
14 bottlesof beer.
Take one down.
pass it around.
13 bottlesof beer on the wall
13 bottlesof beer on the wall
13 bottlesof beer.
Take one down.
pass it around.
12 bottlesof beer on the wall
12 bottlesof beer on the wall
12 bottlesof beer.
Take one down.
pass it around.
11 bottlesof beer on the wall
11 bottlesof beer on the wall
11 bottlesof beer.
Take one down.
pass it around.
10 bottlesof beer on the wall
10 bottlesof beer on the wall
10 bottlesof beer.
Take one down.
pass it around.
9 bottlesof beer on the wall
9 bottlesof beer on the wall
9 bottlesof beer.
Take one down.
pass it around.
8 bottlesof beer on the wall
8 bottlesof beer on the wall
8 bottlesof beer.
Take one down.
pass it around.
7 bottlesof beer on the wall
7 bottlesof beer on the wall
7 bottlesof beer.
Take one down.
pass it around.
6 bottlesof beer on the wall
6 bottlesof beer on the wall
6 bottlesof beer.
Take one down.
pass it around.
5 bottlesof beer on the wall
5 bottlesof beer on the wall
5 bottlesof beer.
Take one down.
pass it around.
4 bottlesof beer on the wall
4 bottlesof beer on the wall
4 bottlesof beer.
Take one down.
pass it around.
3 bottlesof beer on the wall
3 bottlesof beer on the wall
3 bottlesof beer.
Take one down.
pass it around.
2 bottlesof beer on the wall
2 bottlesof beer on the wall
2 bottlesof beer.
Take one down.
pass it around.
1 bottlesof beer on the wall
1 bottleof beer on the wall
1 bottleof beer.
Take one down.
pass it around.
No more bottles of beer on the wall

Process finished with exit code 0

posted @ 2021-08-18 16:36  小风扇呜呜呜  阅读(65)  评论(0)    收藏  举报