Boas amigos, creio que o problema é este mais abaixo quando tem apenas 1, abaixo tem a saida com o codigo do livro:
....
3 bottles of beer on the wall 3 garrafas de cerveja na parede
3 bottles of beer on the wall 3 garrafas de cerveja na parede
3 bottles of beer. 3 garrafas de cerveja
take one down pegue uma
Pass it around. passe adiante
2 bottles of beer on the wall 2 garrafas de cerveja na parede
2 bottles of beer on the wall 2 garrafas de cerveja na parede
2 bottles of beer. 2 garrafas de cerveja
take one down pegue uma
Pass it around. passe adiante
1 bottles of beer on the wall 1 garrafas de cerveja na parede
1 bottle of beer on the wall 1 garrafa de cerveja na parede
....
notem que no final esta com 1 garrafa e ele coloca no plural na primeira vez depois coloca no singular.
corrigi o codigo e ficou assim
package beersong;
public class Main {
public static void main(String[] args) {
int beerNum=99;
String word = "bottles";
while (beerNum > 0) {
if (beerNum ==1){
word="bottle";
}
if (beerNum > 0){
System.out.println(beerNum+ " " + word + " of beer on the wall " );
}
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( "no more bottles of ber on the wall" );
}
}
}
}
Saida com o codigo apresentado:
3 bottles of beer on the wall
3 bottles of beer on the wall
3 bottles of beer.
take one down
Pass it around.
2 bottles of beer on the wall
2 bottles of beer on the wall
2 bottles of beer.
take one down
Pass it around.
1 bottle of beer on the wall
1 bottle of beer on the wall
1 bottle of beer.
take one down
Pass it around.
no more bottles of ber on the wall
desculpe-me ele ter ficado simplificado mas não quis fugir do que foi ensinado no livro, então usei apenas o que foi passado no livro.