I am new to programming. I am trying to use recursion and if-else statement only to print the 99 beers lyrics. Here is my code. How can I make it better to print the lyrics well.
The method countdown prints the lyrics while
countdownB should print the number from number 99 all the way to zero.
public static void countdown(int n) {
if (n== 0) {
System.out.println("no beers");
} else {
System.out.println("more beers");
countdown(n-1);
}
}
public static void countdownB(int x) {
if (x==0){
System.out.print("");
} else {
System.out.print(x);
countdownB(x-1);
}
}
public static void main(String[] args) {
countdownB(3);
countdown(3);
}