I need the song to sing this out from 99 to 0. but when i get to 1 bottle i need it to be formatted the right way. I tried to use an if statement and it works but it doesnt save me the from the loop doing its thing. The format is screwed up the first time the loop gets to it.
public class Example1 {
public static void main(String[] args) {
int counter = 99;
int sum = 0;
while (counter < 100 && counter > 0) {
if (counter >= 2) {
System.out.println(
counter + " bottles of Pepsi on the wall, " + counter + " bottles of Pepsi.");
System.out.println(
"Take one down, pass it around, " + (counter - 1) + " bottles of Pepsi on the wall.");
counter--;
if (counter == 1) {
System.out.println("1 bottle of Pepsi on the wall, 1 bottle of Pepsi.");
System.out.println("Take one down, pass it around, 0 bottles of Pepsi on the wall.");
counter--;
}
}
}
}
}
It needs to look like this on the output at the end.
2 bottles of Pepsi on the wall, 2 bottles of Pepsi.\n
Take one down, pass it around, 1 bottle of Pepsi on the wall.\n
1 bottle of Pepsi on the wall, 1 bottle of Pepsi.\n
Take one down, pass it around, 0 bottles of Pepsi on the wall.\n
Right now it outputs like this.
Take one down, pass it around, 2 bottles of Pepsi on the wall.
2 bottles of Pepsi on the wall, 2 bottles of Pepsi.
Take one down, pass it around, 1 bottles of Pepsi on the wall.
1 bottle of Pepsi on the wall, 1 bottle of Pepsi.
Take one down, pass it around, 0 bottles of Pepsi on the wall.
Any help would be appreciated. Thanks.