How to resolve the algorithm 99 bottles of beer step by step in the uBasic/4tH programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm 99 bottles of beer step by step in the uBasic/4tH programming language
Table of Contents
Problem Statement
Display the complete lyrics for the song: 99 Bottles of Beer on the Wall.
The lyrics follow this form: ... and so on, until reaching 0 (zero). Grammatical support for 1 bottle of beer is optional. As with any puzzle, try to do it in as creative/concise/comical a way as possible (simple, obvious solutions allowed, too).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm 99 bottles of beer step by step in the uBasic/4tH programming language
Source code in the ubasic/4th programming language
0005 LET I=99
0006 PRINT "Lyrics of the song 99 Bottles of Beer"
0010 REM main
0011 IF I>2 THEN GOTO 20
0012 IF I=2 THEN GOTO 30
0013 IF I=1 THEN GOTO 40
0014 GOTO 50
0020 REM if greater than two
0021 PRINT I;" Bottles of beer on the wall, ";I;" bottles of beer."
0022 LET I=I-1
0023 PRINT "Take one down and pass it around, ";
0024 PRINT I;" bottles of beer on the wall."
0025 GOTO 10
0030 REM if equals two
0031 PRINT I;" Bottles of beer on the wall, ";I;" bottles of beer."
0032 LET I=I-1
0033 PRINT "Take one down and pass it around, ";
0034 PRINT I;" bottle of beer on the wall."
0035 GOTO 10
0040 REM if equals one
0041 PRINT I;" Bottle of beer on the wall, ";I;" bottle of beer."
0042 LET I=I-1
0043 PRINT "Take one down and pass it around,";
0044 PRINT " no more bottles of beer on the wall."
0045 GOTO 10
0050 REM if equals zero then exit
0051 PRINT "No more bottles of beer on the wall. No more bottles of beer..."
0052 PRINT "Go to the store and buy some more...99 bottles of beer."
for n=99 to 2 step -1
print n;" bottles of beer on the wall, ";n;" bottles of beer!"
print "Take one down, pass it around, ";n-1;" bottle";
print show(iif(n>2 , "s", ""));" of beer on the wall.\n"
next
print "One bottle of beer on the wall, one bottle of beer!"
print "Take one down, pass it around, no more bottles of beer on the wall.\n"
print "No more bottles of beer on the wall. No more bottles of beer..."
print "Go to the store and buy some more...99 bottles of beer."
You may also check:How to resolve the algorithm Text processing/Max licenses in use step by step in the Tcl programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the RPL programming language
You may also check:How to resolve the algorithm Honeycombs step by step in the Tcl programming language
You may also check:How to resolve the algorithm Polymorphism step by step in the PHP programming language
You may also check:How to resolve the algorithm Determine if a string is numeric step by step in the Common Lisp programming language