- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeer.java
More file actions
Latest commit
44 lines (39 loc) · 1.39 KB
/
Copy pathBeer.java
File metadata and controls
44 lines (39 loc) · 1.39 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//Exercise 9.1
/*99 bottles of beer on the wall,
99 bottles of beer,
ya' take one down, ya' pass it around,
98 bottles of beer on the wall.
...
No bottles of beer on the wall,
no bottles of beer,
ya' can’t take one down, ya' can’t pass it around,
'cause there are no more bottles of beer on the wall!*/
importjava.util.Scanner;
importjava.util.Arrays;
classBeer {
publicstaticvoidmain(String[] args) {
Scannerin = newScanner(System.in);
System.out.println("Enter the number you want to start with:");
intstart = in.nextInt();
lyrics(start);
}
publicstaticvoidlyrics(intn) {
for (inti = n; i >= 0; i--) {
if (i == 0) {
System.out.println("No bottles of beer on the wall,");
System.out.println("no bottles of beer,");
System.out.println("ya' can't take one down, ya' can't pass it around");
System.out.println("'cause there are no more bottles of beer on the wall!");
} else {
part(i);
}
}
}
publicstaticvoidpart(intnumber) {
System.out.println(number + " bottles of beer on the wall,");
System.out.println(number + " bottles of beer,");
System.out.println("ya' take one down, ya' pass it around,");
System.out.println((number - 1) + " bottles of beer on the wall.");
System.out.println();
}
}