99 Bottles of Beer
#1
A 99 Bottles of Beer program is a computer program that generates the lyrics of the song "99 Bottles of Beer".

in case you don't know the song you can find the lyrics here

Code:
https://en.wikipedia.org/wiki/99_Bottles_of_Beer

Code:
public class Beer {
    
    public static void main (String args[]) {
        int bottles=99;
        for(int i=0;i<99;i++){
        System.out.println(bottles+ "bottles of beer on the wall");
        System.out.println(bottles+ "bottles of beer");
        System.out.println("Take one down, pass it around");
        System.out.println((bottles-1)+ "bottles of beer on the wall");
        bottles--;
        }
    }
}
Reply
#2
Instead of using i to count, why didn't you just use bottles variable directly?
Code:
int bottles = 99;
while (bottles > 0)
{
  printf("%d bottles of beer on the wall, %d bottles of beer\n"
  "take one down, pass it around, %d bottles of beer on the wall\n\n", bottles, bottles, bottles);
  --bottles;
}
Reply
#3
yep your right, i have no idea why i did it like this at that time
Reply