info10:aufgaben:trinklied
Inhaltsverzeichnis
Das Trinklied
99 bottles of beer on the wall
Aufgabe
- Höre Dir das Lied zunächst hier an.
- Schreibe ein Programm, das das Trinklied „99 bottles of beer“ ausgibt.
- Verwende eine geeignete Wiederholungsschleife und führe eine Variable für die Anzahl der noch vorhandenen Flaschen ein.
- Beachte dabei, dass das Programm den Plural und den Singular von „botlles“ korrekt ausgibt (bedingten Anweisung). Schreibe dazu eine Methode, die je nach Anzahl vorhandener Flaschen, entweder „bottle“ (Singular) oder „bottles“ (Plural) zurück gibt.
Ausgabe
99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. Take one down and pass it around, 96 bottles of beer on the wall. ... 3 bottles of beer on the wall, 3 bottles of beer. Take one down and pass it around, 2 bottles of beer on the wall. 2 bottles of beer on the wall, 2 bottles of beer. Take one down and pass it around, 1 bottle of beer on the wall. 1 bottle of beer on the wall, 1 bottle of beer. Take one down and 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.
info10/aufgaben/trinklied.txt · Zuletzt geändert: 2025/03/29 13:14 von 127.0.0.1