99 bottles of beer csharp example

esse quam videri
Revision as of 07:35, 17 September 2007 by Jeff (talk | contribs)
Jump to: navigation, search

99 bottles of beer lyrics

Simple count down with while loop

[[1]]

The simple version uses three variables <csharp> string strBottles = "bottles"; string strLineOne = ""; int intBottles = 99; </csharp>

The string strBottles is used to change the word 'bottles' to bottle when the bottle count gets to 1.

2 bottles of beer on the wall.  is correct but
1 bottles of beer on the wall is not so we will use a variable and an if stement to change the
word bottles to bottle if the intBottles variable = 1

<csharp>

           //Check for 1 bottle of beer
           if (intBottles==1) 
           {
               strBottles = " bottle"; //fix 1 bottle of beer
           }

</csharp>

The song sung the correct way

http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class3/99Bottles/99Bottles_whileFull.cs