Advertisement
Guest User

99 Bottles of Beer

a guest
Aug 8th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author Javanian
  4.  */
  5. class bottles
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.         int n = bottles(99);
  10.      }
  11.     static int bottles (int n)
  12.     {
  13.         if(n==0)
  14.         {
  15.             System.out.println("No more bottles of beer on the wall, no more bottles on the wall \n Go to the store and buy some more, 99 bottles of beer on the wall");
  16.             return 0;  
  17.         }
  18.         if(n==1)
  19.         {
  20.             System.out.println(n + " bottle of beer on the wall, " + n + " bottle of beer\n Take one down and pass it around, no more bottles of beer on the wall");
  21.             return(bottles(n-1) );
  22.         }
  23.         else
  24.         {
  25.             System.out.println(n + " bottles of beer on the wall, " + n + " bottles of beer\n Take one down and pass it around, " +( n-1) + " bottles of beer on the wall");
  26.             return(bottles(n-1) );
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement