-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeerSong.java
More file actions
30 lines (22 loc) · 817 Bytes
/
BeerSong.java
File metadata and controls
30 lines (22 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class BeerSong {
public static void main(String[] args) {
BeerSong.Ninety_Nine_Bottles_of_Beer();
}
static void Ninety_Nine_Bottles_of_Beer() {
int beerNum = 99;
String x = "bottles";
while (beerNum > 0) {
System.out.println(beerNum + " " + x + " of beer on the wall, " + beerNum + " " + x + " of beer");
beerNum = beerNum - 1;
if (beerNum == 1) {
x = "bottle"; //removes "s"
}
if (beerNum > 0) {
System.out.println("Take one down, pass it around " + beerNum + " " + x + " of beer on the wall");
}
}
if (beerNum == 0) {
System.out.println("Take one down, pass it around, no more bottles of beer on the wall");
}
}
}