Java :: Aufgabe #43 :: Lösung #6
6 Lösungen

#43
99 Bottles of Beer - Selbstständige Lösung
Anfänger - Java
von pocki
- 11.01.2013 um 14:07 Uhr
Programmiere eine eigenständige Lösung zur gängigen Programmier-Übung bzw. Lied 99 Bottles of Beer
Ausgabe:
Ausgabe:
Konsolenausgabe:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 99 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
... usw.
#6

von paddlboot (3970 Punkte)
- 09.07.2019 um 08:53 Uhr

public class beerbottles { public static void main(String[] args) { for(int i = 99; i > 0; i--) { if(i == 2) { System.out.println(i + " bottles of beer on the wall, " + i + " bottles of beer."); System.out.println("Take one down and pass it around, one last bottle of beer on the wall.\n"); } else if(i == 1) { System.out.println("One last bottle of beer on the wall, one last bottle of beer."); System.out.println("Take it down, pass it around,\nNo more bottles of beer on the wall."); } else { System.out.println(i + " bottles of beer on the wall, " + i + " bottles of beer."); System.out.println("Take one down and pass it around, " + (i-1) + " bottles of beer on the wall.\n"); } } } }
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1