Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import UIKit
  2.  
  3. //Written by Joseph Rogers
  4. //For use in Xcode
  5.  
  6. func beerSongForThisManyBottlesOfBeer(_ howManyBottles : Int) -> String {
  7. var lyrics: String = ""
  8.  
  9. for number in (2...howManyBottles).reversed() {
  10. let newLine: String = "\n\(number) bottles of beer on the wall, \(number) bottles of beer. \nTake one down and pass it around, \(number - 1) bottles of beer on the wall.\n"
  11. lyrics += newLine
  12. }
  13.  
  14. lyrics += "\n1 bottle of beer on the wall, 1 bottle of beer. \nTake one down and pass it around, no more bottles of beer on the wall.\n"
  15. lyrics += "\nNo more bottles of beer on the wall, no more bottles of beer. \nGo to the store and buy some more, 99 bottles of beer on the wall."
  16.  
  17. return lyrics
  18. }
  19.  
  20.  
  21. print(beerSongForThisManyBottlesOfBeer(99))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement