forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNinetyNineBottles.java
More file actions
29 lines (19 loc) · 883 Bytes
/
NinetyNineBottles.java
File metadata and controls
29 lines (19 loc) · 883 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
package com.zetcode;
public class NinetyNineBottles {
public static void main(String[] args) {
// 99 bottles of beer on the wall, 99 bottles of beer.
// Take one down, pass it around, 98 bottles of beer on the wall
int nOfbottles = 99;
for (int i = nOfbottles; i >= 1; i--) {
if (i == 1) {
System.out.printf("%d bottle of beer on the wall, %d bottle of beer.%n", i, i);
System.out.println("Take one down, pass it around, no bottles of beer on the wall.");
System.out.println();
} else {
System.out.printf("%d bottles of beer on the wall, %d bottles of beer.%n", i, i);
System.out.printf("Take one down, pass it around, %d bottles of beer on the wall.%n", i - 1);
System.out.println();
}
}
}
}