-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBottleSong.java
More file actions
26 lines (20 loc) · 774 Bytes
/
BottleSong.java
File metadata and controls
26 lines (20 loc) · 774 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
public class BottleSong {
public static void main(String[] args) {
int bottlesNum = 10;
String word = "bottles";
while (bottlesNum > 0) {
System.out.println(bottlesNum + " green " + word + ", hanging on the wall");
System.out.println(bottlesNum + " green " + word + ", hanging on the wall");
System.out.println("And if one green bottle should accidentally fall,");
bottlesNum = bottlesNum - 1;
if (bottlesNum == 1){
word = "bottle";
}
if (bottlesNum > 0){
System.out.println("There'll be " + bottlesNum +" green " + word + ", hanging on the wall\n");
} else {
System.out.println("There'll be no green bottles, hanging on the wall");
} // end else
} // end while loop
} // end main method
} // end class