Answer Key

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

One way to solve this is as follows:

  var sam = 28.32
  var edith = 18.75
  var katie = 21.61
  var kayla = 24.92

  var total = sam + edith + katie + kayla
  var tenPercent = total + (total * 0.10)
  var fifteenPercent = total + (total * 0.15)
  var twentyPercent = total + (total * 0.20)

  print("🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦")
  print(" Sam's bill:   28.32  ")
  print(" Edith's bill: 18.75  ")
  print(" Katie's bill: 21.61  ")
  print(" Kayla's bill: 24.92  ")
  print("🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦")
  print("Total: \(total)")
  print("10%: \(tenPercent)")
  print("15%: \(fifteenPercent)")
  print("20%: \(twentyPercent)")
  print("🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦")

Remember: Your version doesn’t have to be identical!

See forum comments
Download course materials from Github
Previous: Deliverables