Monday, October 02, 2006

Code Chunking

The idea of "Code Chunking" is from David L's Blog. When I read his article, "Better Code through Chunking!", I realized that "Code Chunking" is what "Sharing Java" is all about, and has been for a while.

Code chunking would be different from GoF. Expert programmers do not think too much about how to construct their program, but intuitively know what to do when programming, more or less...

I found more ideas about code chunking from these places:

Monday, June 26, 2006

Temperature Conversion

Program

package bloggingjava;

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        // temperature conversion
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("deg F\t\tdeg C");
        for(; ; ) {
            System.out.println("Enter deg F");
            double F = Double.parseDouble(stdin.readLine());
            System.out.println(F + "\t\t" + (F - 32) / 1.8);
            // no break statement
        }
    }
}

Output

deg F           deg C
Enter deg F
32
32.0            0.0
Enter deg F
50
50.0            10.0
Enter deg F
68
68.0            20.0
Enter deg F
Ctrl+C  

References

Friday, June 09, 2006

Vickers 1980

Reference Vickers 1980
Author Steven Vickers
Year 1980
Title Sinclair ZX81 BASIC Programming
Publisher Sinclair Research Limited
Retrieved 07 june 2006
URL ftp://ftp.worldofspectrum.org/pub/sinclair/hardware-info/ZX81_BasicProgramming.pdf

Sunday, May 21, 2006

Vleck 1982

Author Tom Van Vleck
Year 1982
Title Real Programmers Don't Write Specs
Retrieved Wednesday, April 13, 2005
URL http://www.multicians.org/thvv/realprogs.html

Dahl, Myrhaug & Nygaard 1970

Reference Dahl, Myrhaug & Nygaard 1970
Author Ole-Johan Dahl, Bjørn Myrhaug & Kristen Nygaard
Year 1970
Title Common Base Language
Place Oslo
Publisher Norwegian Computing Center
Retrieved 21. may, 2006
URL http://www.fh-jena.de/~kleine/history/languages/Simula-CommonBaseLanguage.pdf

Friday, May 19, 2006

Bloch 2001

Reference Bloch 2001
Author Joshua Bloch
Year 2001
Title Effective Java, Programming language Guide
Place Boston
Publisher Addison-Wesley

Saturday, May 13, 2006

Orwell 1945

Author Orwell, George
Year 1945
Title Animal Farm
Retrieved May 13, 2006
URL http://www.online-literature.com/orwell/animalfarm/

Wednesday, May 10, 2006

References

Pointers in Java are called references. I guess pointers are called references because you can't do any arithmetic pointer operations on them (reference needed).

Before creating objects from the class, you will need a reference that can point to where the object is stored in memory. A reference is a kind of variable that stores addresses to memory locations.

A reference is necessary when you want to handle an object. If you want to access the object you need a reference. Also, an object that is not pointed to, may get destroyed anytime by the garbage collector, because it assumes that the program no longer need to access the object.

Concept: An object no longer pointed to, is a dead object.

package animalfarm;

class Dog {
}

public class Main {
    public static void main(String[] args) {
        Dog dog;
    }
}

The statement Dog dog; creates a new reference. The name of the reference is dog, and the reference may point to objects of type Dog. The reference does not yet point to anything, because it contains no value.

Thursday, April 13, 2006

Backus 1978

Author Backus, John
Year 1978
Title The History of FORTRAN I, II, and III.
Place San Jose, California
Publisher IBM Research Laboratory
Retrieved April 13, 2006
URL http://community.computerhistory.org/scc/projects/FORTRAN/paper/p165-backus.pdf

Tuesday, April 11, 2006

Pea 1986

Author Roy D. Pea
Year 1986
Title Language-Independent Conceptual "Bugs" in Novice Programming
Publisher Baywood Publishing Co., Inc.
Retrieved April 11, 2006
URL http://scil.stanford.edu/about/staff/bios/PDF/Lang_bugs

The Egocentrism Bug

Introduction

The "egocentrism bug" is the thought that the computer can fill in what you forgot to write, or somehow interpret the correct meaning of a statement (Pea 1986). There is of course no more meaning in the program than what is written in the code.

Program

You have to tell the computer exactly what it is supposed to do. The computer can't understand what a statement is supposed to mean. For instance, the computer never stops executing a program, asking itself what it is doing, or if what it does is worth doing... So, sometimes the computer hangs!

public class Main {
    public static void main(String[] args) {
        while (true) {
            System.out.println("All Work and No Play Makes Jack a Dull Boy. ");
        }    
    }
}

References

Monday, April 10, 2006

The Intentionality Bug

Introduction

The "intentionality bug" is the thought that the computer computer has goal directedness or foresightedness, and is able to go beyond the information given in the program (Pea 1986). Of course, the computer will only be concerned about the current statement and only the current statement.

References

The Parallelism Bug

Introduction

The computer can process one and only one statement at a time, and no more. The "parallelism bug" is the thought that the computer knows about and can process several statements at the same time, somehow in parallel (Pea 1986). Of course, several lines of code can't be active or known by the computer at the same time.

Program

public class Main {    
    public static void main(String[] args) {
        int size = 0;
        for (size = 1; size <= 10; size++) System.out.println(size);
        System.exit(0); // terminate program
        if (size == 10) System.out.println("Hello");
    }
}

According to Pea (1986) students think that when size is equal to ten in the for loop, "Hello" is printed. Of course, in this program, the if (size == 10) System.out.println("Hello"); statement will never be reached.

References

Saturday, April 08, 2006

Grammars

Introduction

All programming language grammars at http://www.lykkenborg.no/ are written in ISO/IEC 14977:1996 EBNF notation.

Discussion

Using the grammars

Usually, you start by clicking the goal symbol CompilationUnit at the top of the document and continue clicking in a top-down fashion. But you could also click the goal symbol Input and continue in a bottom-up order. Read other rule definitions by clicking on the rule name. It is also possible to find the rules that references terminal and nonterminal symbols, by looking up the symbol in the index.

Conventions

The grammars uses the following BNF-style conventions:

  • [x] denotes zero or one occurrences of x.
  • (x y) denotes grouping of x and y.
  • x | y means one of either x or y.
  • x, y means both x and y.
  • x - y means x but not y.

References

Sunday, March 19, 2006

Java

Introduction

The Java programming language is related to C and C++, but includes ideas from several other languages (Gosling et al. 2000).

References

C

Introduction

The computer language C is a descendant from B (Kernighan & Ritchie 1988:1).

References

  • Kernighan, Brian W. & Dennis M. Ritchie. (1988). The C programming language. New Jersey: Prentice Hall.

B

Introduction

The computer language B is a directly descendant from BCPL (Thompson 1972:1).

References

Author Thompson, Ken
Year 1972
Title Users' Reference to B
Place
Publisher Bell Laboratories
Retrieved March 19, 2005
URL http://cm.bell-labs.com/cm/cs/who/dmr/kbman.html

Saturday, March 18, 2006

Statements

Introduction

If you want your program to do anything at all, you will have to write statements. Just like the sentence is the smallest structure that make any sense to humans, a statement is the smalest structure that make any sense to the computer. Statements consists of tokens and expressions, like sentences consist of words and phrases in English.

A statement is similar to a sentence in a natural language like English, except that a statement tell the computer how to do something.

Concept: A statement is the smallest part of a program that the computer can understand.

Program

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Discussion

In the application above, System.out.println("Hello World!"); is a statement, and the only line which actually does something.

A statement in Java must be terminated with the semicolon, the ';' character.

Exercise

The following is the Java grammar for a Java statement:

Statement =
StatementWithoutTrailingSubstatement | LabeledStatement | IfThenStatement | IfThenElseStatement | WhileStatement | ForStatement ;

The grammar look more difficult than it really is. Just click around in the grammar to get a feeling what you may do with a statement.

Wednesday, March 15, 2006

The Semicolon

Introduction

The semicolon, ;, was invented by Aldus Manutius the elder (1450-1515), an Italian printer. Manutius used the semicolon to separate words opposed in meaning and to mark off mutually dependent statements (http://en.wikipedia.org/wiki/Semicolon).

The semicolon in Java works much the same way as the punctuation mark in English. The punctuation mark terminates a sentence in English, so that you may write several sentences following each other. The semicolon in Java terminates a statement, so that you may write several statements following each other in sequence.

Discussion

So, why does most programming languages use the semicolon instead of the punctuation mark? The answer is that the semicolon is supposed to do several things. The semicolon terminates statements, separate statements and concatenates statements. Besides, the punctuation mark is used for other purposes.

The Order of Execution

Statements are executed one at a time, from top to bottom, left to right. The computer gets one statement and executes it, and then gets the next statement followed by the semicolon.

Key Concept: A sequence is ordered statements that are executed in the same order as written. Statements are sequenced (ordered) by the semicolon.

Key Concept: Any statement which does not perform an explicit jump, actually performs an implicit jump to the next statement because of the semicolon.

Note: The semicolon is not an operator because operators are used to combine factors in an expression. That is, operators are not used to combine statements.

Consider the code:
class StarTrek {
    public static void main(String[] args) {
        System.out.println("              Space, the final frontier.");
        System.out.println();
        System.out.println("   These are the voyages of the Starship Enterprise.");
        System.out.println("Its continuing mission: to explore strange new worlds;");
        System.out.println("      to seek out new life and new civilizations;");
        System.out.println("      to boldly go where no one has gone before.");
    }
}
[user]$ javac StarTrek.java
[user]$ java StarTrek
              Space, the final frontier.

   These are the voyages of the Starship Enterprise.
Its continuing mission: to explore strange new worlds;
      to seek out new life and new civilizations;
      to boldly go where no one has gone before.

Obviously, the order of execution is normally of importance for the result. The Star Trek mission statement would not give any meaning stated in a different order.

Readability

Semicolons may make a program look cluttered, but with semicolons, long statements can run over several lines with new line almost anywhere you prefer. With semicolon, several statements can also be placed on the same line, but this should generally be avoided. It was usually done to save print paper on old computers without a monitor. A statement should be written beneath the statement above, because of readability.

How to terminate statements

Placement

In Java, each statement must be followed by the ; character. Even the last statement must be followed by the semicolon, so that you do not forget to add the semicolon if you later have to move the statement. It would also be confusing if some statements need semicolon and some statements don't. In the programming language Pascal, you don't need semicolon after the last statement. Now, what happens if you later have to move the last statement and you sort of forget adding the semicolon? This is a constant source of compilation errors in Pascal. The solution is to add an empty statement, the semicolon, after the last statement, which by "coincidence" is what you have to do in Java anyway.

Each individual statement is terminated by a semicolon. (The C programming language, Second Edition, 1988, Brian W. Kernighan, Dennis M. Ritchie. Prentice Hall, s. 10.)

The semicolon is a statement terminator in Java, rather than a separator. Java got this from C: "In C, the semicolon is a statement terminator, rather than a separator as it is in languages like Pascal." (The C programming language, Second Edition, 1988, Brian W. Kernighan, Dennis M. Ritchie. Prentice Hall, s. 55.).

In Java, each statement must be terminated with the semicolon. Even the last statement must be terminated with semicolon, because it is easy to forget to add the semicolon if you later have to move some statements. Also, it would be confusing if some statements need semicolon and some statements don't.

The goon Symbol

The semicolon means that after this statement has been executed and terminated, then go on to the next statement following this statement. (Lykkenborg 2005)

C got the semicolon from ALGOL 68. The ALGOL 68 semicolon is called the GOON SYMBOL pronounced "go on" (http://www.flashdance.cx/txt/Hacking_text/Hacker_Ordlista.txt).

The 'go on symbols' (better known as semicolons) constitute the mortar which bind the bricks together (Lindsey & Meulen 1974).

  3.0.7. Sequencing tokens
  go on symbol        ;
  completion symbol   .
  go to symbol        go to
(Wijngaarden et al. 1968).

The Empty Statement

The empty statement denotes the null action (Wirth 1983).

The Sequence

"The most basic structure is the sequence. A computation is a sequence of actions, where each action is specified by a statement, and is executed after the preceding action is completed. This strict sequentiality in time is an essential assumption of sequential programming. If a statement S1 follows S0, then we indicate this sequentiality by a semicolon S0; S1" (Wirth 1983:17).

The Statement Separator

"This statement separator (not terminator) indicates that the action specified by S0 is to be followed immediately by the action corresponding to S1." (Wirth 1983:17).

References

Author Wirth, Niklaus
Year 1983
Title Programming in Modula-2, Second Edition
Place Berlin Heidelberg New York
Publisher Springer-Verlag
Retrieved
URL

Author Wijngaarden, A. van (editor), Mailloux, B. J., Peck, J.E.L. & Koster, C.H.A.
Year 1968
Title Draft report on the algorithmic language ALGOL 68, third printing
Place Amsterdam
Publisher Mathematisch centrum
Retrieved
URL

Author Lindsey, C.H., Meulen, SG. van der
Year 1974
Title Informal Introduction to Algol 68
Place
Publisher
Retrieved
URL

Wednesday, March 08, 2006

Binomial Coefficient

Introduction

Binomial Coefficient, nCr = n! / ((n - r)! * r!).

Discussion

This code was derived from algorithms after Manolopoulos (2002) and User Contributed Notes (2006).

package math;

public final class Main {

    /**
     * Don't let anyone instantiate this class.
     */
    private Main() {
    }
    
    public static long binomialCoefficient(int n, int r) {
        long t = 1;
        
        int m = n - r; // r = Math.max(r, n - r);
        if (r < m) {
            r = m;
        }
        
        for (int i = n, j = 1; i > r; i--, j++) {
            t = t * i / j;
        }
        
        return t;
    }
    
    public static void main(String[] args) {
        // possible combinations of cards in a poker hand
        System.out.println(binomialCoefficient(52, 5)); // 2598960
        
        // possible combinations of numbers in lottery
        System.out.println(binomialCoefficient(49, 6)); // 13983816
    }
}

References

Author Manolopoulos, Yannis
Year 2002
Title Binomial Coefficient Computation: Recursion or Iteration?
Publisher ACM SIGCSE Bulletin, Volume 34, Issue 4

Author User Contributed Notes
Year 2006
Title Mastering Algorithms with Perl (Owant). In: LXXII. Mathematical Functions
Publisher php
Retrieved March 8, 2006 from http://php.morva.net/manual/en/ref.math.php

Tuesday, February 07, 2006

99 Bottles of Beer on the Wall

Introduction

This program generate the lyrics (99 Bottles of Beer & others 2006) to the song "99 Bottles of Beer on the Wall".

Discussion

/*
 * "99 Bottles of Beer on the Wall"
 */

package bloggingjava;

public class Bottles {
    
    public static String bottles(int b) {
        String s = "";

        switch (b) {
        case 0:
            s = "no more bottles"; 
            break;

        case 1:
            s = "1 bottle"; 
            break;

        default:
            s = b + " bottles";
            break;
        }
        
        return s;
    }
    
    public static void main(String[] args) {
        String s1 = " of beer";
        String s2 = " on the wall";
        
        for (int i = 99; i != 0; ) {
            System.out.print(bottles(i) + s1 + s2 + ", ");
            System.out.print(bottles(i) + s1 + ".\n");
            
            System.out.print("Take one down, pass it around, ");
            System.out.print(bottles(--i) + s1 + s2 + ".\n\n");
        }
        
        System.out.print(bottles(0).substring(0, 1).toUpperCase() + bottles(0).substring(1) + s1 + s2 + ", ");
        System.out.print(bottles(0) + s1 + ".\n");
        
        System.out.print("Go to the store and buy some more, "); 
        System.out.print(bottles(99) + s1 + s2 + ".\n\n");
    }
}
99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down, pass it around, 97 bottles of beer on the wall.

97 bottles of beer on the wall, 97 bottles of beer.
Take one down, pass it around, 96 bottles of beer on the wall.

96 bottles of beer on the wall, 96 bottles of beer.
Take one down, pass it around, 95 bottles of beer on the wall.

95 bottles of beer on the wall, 95 bottles of beer.
Take one down, pass it around, 94 bottles of beer on the wall.

94 bottles of beer on the wall, 94 bottles of beer.
Take one down, pass it around, 93 bottles of beer on the wall.

93 bottles of beer on the wall, 93 bottles of beer.
Take one down, pass it around, 92 bottles of beer on the wall.

92 bottles of beer on the wall, 92 bottles of beer.
Take one down, pass it around, 91 bottles of beer on the wall.

91 bottles of beer on the wall, 91 bottles of beer.
Take one down, pass it around, 90 bottles of beer on the wall.

90 bottles of beer on the wall, 90 bottles of beer.
Take one down, pass it around, 89 bottles of beer on the wall.

89 bottles of beer on the wall, 89 bottles of beer.
Take one down, pass it around, 88 bottles of beer on the wall.

88 bottles of beer on the wall, 88 bottles of beer.
Take one down, pass it around, 87 bottles of beer on the wall.

87 bottles of beer on the wall, 87 bottles of beer.
Take one down, pass it around, 86 bottles of beer on the wall.

86 bottles of beer on the wall, 86 bottles of beer.
Take one down, pass it around, 85 bottles of beer on the wall.

85 bottles of beer on the wall, 85 bottles of beer.
Take one down, pass it around, 84 bottles of beer on the wall.

84 bottles of beer on the wall, 84 bottles of beer.
Take one down, pass it around, 83 bottles of beer on the wall.

83 bottles of beer on the wall, 83 bottles of beer.
Take one down, pass it around, 82 bottles of beer on the wall.

82 bottles of beer on the wall, 82 bottles of beer.
Take one down, pass it around, 81 bottles of beer on the wall.

81 bottles of beer on the wall, 81 bottles of beer.
Take one down, pass it around, 80 bottles of beer on the wall.

80 bottles of beer on the wall, 80 bottles of beer.
Take one down, pass it around, 79 bottles of beer on the wall.

79 bottles of beer on the wall, 79 bottles of beer.
Take one down, pass it around, 78 bottles of beer on the wall.

78 bottles of beer on the wall, 78 bottles of beer.
Take one down, pass it around, 77 bottles of beer on the wall.

77 bottles of beer on the wall, 77 bottles of beer.
Take one down, pass it around, 76 bottles of beer on the wall.

76 bottles of beer on the wall, 76 bottles of beer.
Take one down, pass it around, 75 bottles of beer on the wall.

75 bottles of beer on the wall, 75 bottles of beer.
Take one down, pass it around, 74 bottles of beer on the wall.

74 bottles of beer on the wall, 74 bottles of beer.
Take one down, pass it around, 73 bottles of beer on the wall.

73 bottles of beer on the wall, 73 bottles of beer.
Take one down, pass it around, 72 bottles of beer on the wall.

72 bottles of beer on the wall, 72 bottles of beer.
Take one down, pass it around, 71 bottles of beer on the wall.

71 bottles of beer on the wall, 71 bottles of beer.
Take one down, pass it around, 70 bottles of beer on the wall.

70 bottles of beer on the wall, 70 bottles of beer.
Take one down, pass it around, 69 bottles of beer on the wall.

69 bottles of beer on the wall, 69 bottles of beer.
Take one down, pass it around, 68 bottles of beer on the wall.

68 bottles of beer on the wall, 68 bottles of beer.
Take one down, pass it around, 67 bottles of beer on the wall.

67 bottles of beer on the wall, 67 bottles of beer.
Take one down, pass it around, 66 bottles of beer on the wall.

66 bottles of beer on the wall, 66 bottles of beer.
Take one down, pass it around, 65 bottles of beer on the wall.

65 bottles of beer on the wall, 65 bottles of beer.
Take one down, pass it around, 64 bottles of beer on the wall.

64 bottles of beer on the wall, 64 bottles of beer.
Take one down, pass it around, 63 bottles of beer on the wall.

63 bottles of beer on the wall, 63 bottles of beer.
Take one down, pass it around, 62 bottles of beer on the wall.

62 bottles of beer on the wall, 62 bottles of beer.
Take one down, pass it around, 61 bottles of beer on the wall.

61 bottles of beer on the wall, 61 bottles of beer.
Take one down, pass it around, 60 bottles of beer on the wall.

60 bottles of beer on the wall, 60 bottles of beer.
Take one down, pass it around, 59 bottles of beer on the wall.

59 bottles of beer on the wall, 59 bottles of beer.
Take one down, pass it around, 58 bottles of beer on the wall.

58 bottles of beer on the wall, 58 bottles of beer.
Take one down, pass it around, 57 bottles of beer on the wall.

57 bottles of beer on the wall, 57 bottles of beer.
Take one down, pass it around, 56 bottles of beer on the wall.

56 bottles of beer on the wall, 56 bottles of beer.
Take one down, pass it around, 55 bottles of beer on the wall.

55 bottles of beer on the wall, 55 bottles of beer.
Take one down, pass it around, 54 bottles of beer on the wall.

54 bottles of beer on the wall, 54 bottles of beer.
Take one down, pass it around, 53 bottles of beer on the wall.

53 bottles of beer on the wall, 53 bottles of beer.
Take one down, pass it around, 52 bottles of beer on the wall.

52 bottles of beer on the wall, 52 bottles of beer.
Take one down, pass it around, 51 bottles of beer on the wall.

51 bottles of beer on the wall, 51 bottles of beer.
Take one down, pass it around, 50 bottles of beer on the wall.

50 bottles of beer on the wall, 50 bottles of beer.
Take one down, pass it around, 49 bottles of beer on the wall.

49 bottles of beer on the wall, 49 bottles of beer.
Take one down, pass it around, 48 bottles of beer on the wall.

48 bottles of beer on the wall, 48 bottles of beer.
Take one down, pass it around, 47 bottles of beer on the wall.

47 bottles of beer on the wall, 47 bottles of beer.
Take one down, pass it around, 46 bottles of beer on the wall.

46 bottles of beer on the wall, 46 bottles of beer.
Take one down, pass it around, 45 bottles of beer on the wall.

45 bottles of beer on the wall, 45 bottles of beer.
Take one down, pass it around, 44 bottles of beer on the wall.

44 bottles of beer on the wall, 44 bottles of beer.
Take one down, pass it around, 43 bottles of beer on the wall.

43 bottles of beer on the wall, 43 bottles of beer.
Take one down, pass it around, 42 bottles of beer on the wall.

42 bottles of beer on the wall, 42 bottles of beer.
Take one down, pass it around, 41 bottles of beer on the wall.

41 bottles of beer on the wall, 41 bottles of beer.
Take one down, pass it around, 40 bottles of beer on the wall.

40 bottles of beer on the wall, 40 bottles of beer.
Take one down, pass it around, 39 bottles of beer on the wall.

39 bottles of beer on the wall, 39 bottles of beer.
Take one down, pass it around, 38 bottles of beer on the wall.

38 bottles of beer on the wall, 38 bottles of beer.
Take one down, pass it around, 37 bottles of beer on the wall.

37 bottles of beer on the wall, 37 bottles of beer.
Take one down, pass it around, 36 bottles of beer on the wall.

36 bottles of beer on the wall, 36 bottles of beer.
Take one down, pass it around, 35 bottles of beer on the wall.

35 bottles of beer on the wall, 35 bottles of beer.
Take one down, pass it around, 34 bottles of beer on the wall.

34 bottles of beer on the wall, 34 bottles of beer.
Take one down, pass it around, 33 bottles of beer on the wall.

33 bottles of beer on the wall, 33 bottles of beer.
Take one down, pass it around, 32 bottles of beer on the wall.

32 bottles of beer on the wall, 32 bottles of beer.
Take one down, pass it around, 31 bottles of beer on the wall.

31 bottles of beer on the wall, 31 bottles of beer.
Take one down, pass it around, 30 bottles of beer on the wall.

30 bottles of beer on the wall, 30 bottles of beer.
Take one down, pass it around, 29 bottles of beer on the wall.

29 bottles of beer on the wall, 29 bottles of beer.
Take one down, pass it around, 28 bottles of beer on the wall.

28 bottles of beer on the wall, 28 bottles of beer.
Take one down, pass it around, 27 bottles of beer on the wall.

27 bottles of beer on the wall, 27 bottles of beer.
Take one down, pass it around, 26 bottles of beer on the wall.

26 bottles of beer on the wall, 26 bottles of beer.
Take one down, pass it around, 25 bottles of beer on the wall.

25 bottles of beer on the wall, 25 bottles of beer.
Take one down, pass it around, 24 bottles of beer on the wall.

24 bottles of beer on the wall, 24 bottles of beer.
Take one down, pass it around, 23 bottles of beer on the wall.

23 bottles of beer on the wall, 23 bottles of beer.
Take one down, pass it around, 22 bottles of beer on the wall.

22 bottles of beer on the wall, 22 bottles of beer.
Take one down, pass it around, 21 bottles of beer on the wall.

21 bottles of beer on the wall, 21 bottles of beer.
Take one down, pass it around, 20 bottles of beer on the wall.

20 bottles of beer on the wall, 20 bottles of beer.
Take one down, pass it around, 19 bottles of beer on the wall.

19 bottles of beer on the wall, 19 bottles of beer.
Take one down, pass it around, 18 bottles of beer on the wall.

18 bottles of beer on the wall, 18 bottles of beer.
Take one down, pass it around, 17 bottles of beer on the wall.

17 bottles of beer on the wall, 17 bottles of beer.
Take one down, pass it around, 16 bottles of beer on the wall.

16 bottles of beer on the wall, 16 bottles of beer.
Take one down, pass it around, 15 bottles of beer on the wall.

15 bottles of beer on the wall, 15 bottles of beer.
Take one down, pass it around, 14 bottles of beer on the wall.

14 bottles of beer on the wall, 14 bottles of beer.
Take one down, pass it around, 13 bottles of beer on the wall.

13 bottles of beer on the wall, 13 bottles of beer.
Take one down, pass it around, 12 bottles of beer on the wall.

12 bottles of beer on the wall, 12 bottles of beer.
Take one down, pass it around, 11 bottles of beer on the wall.

11 bottles of beer on the wall, 11 bottles of beer.
Take one down, pass it around, 10 bottles of beer on the wall.

10 bottles of beer on the wall, 10 bottles of beer.
Take one down, pass it around, 9 bottles of beer on the wall.

9 bottles of beer on the wall, 9 bottles of beer.
Take one down, pass it around, 8 bottles of beer on the wall.

8 bottles of beer on the wall, 8 bottles of beer.
Take one down, pass it around, 7 bottles of beer on the wall.

7 bottles of beer on the wall, 7 bottles of beer.
Take one down, pass it around, 6 bottles of beer on the wall.

6 bottles of beer on the wall, 6 bottles of beer.
Take one down, pass it around, 5 bottles of beer on the wall.

5 bottles of beer on the wall, 5 bottles of beer.
Take one down, pass it around, 4 bottles of beer on the wall.

4 bottles of beer on the wall, 4 bottles of beer.
Take one down, pass it around, 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 beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

References

Author 99 Bottles of Beer Team
Year 2006
Title 99 Bottles of Beer
Place
Publisher 99 Bottles of Beer Team
Retrieved April 7, 2006
URL http://www.99-bottles-of-beer.net/