Challenge

  1. Add a header to the third section, saying “Amount per person”
Section {
		Text(totalPerPerson, format: currencyFormat)
} header: {
    Text("Amount per person")
}

  1. Add another section showing the total amount for the check – i.e., the original amount plus tip value, without dividing by the number of people.
var totalAmount: Double {
		checkAmount + (checkAmount / 100 * Double(tipPercentage))
}

Section {
		Text(totalAmount, format: currencyFormat)
} header: {
    Text("Total amount")
}
  1. Change the tip percentage picker to show a new screen rather than using a segmented control, and give it a wider range of options – everything from 0% to 100%. Tip: use the range 0..<101 for your range rather than a fixed array.
Picker("Number of people", selection: $numberOfPeople) {
		ForEach(2..<100) {
		    Text("\\($0) people")
    }
}
  1. Make a new property to store the currency formatter(.currency(code: Locale.current.currencyCode ?? "USD")).
var currencyFormat: FloatingPointFormatStyle<Double>.Currency {
    .currency(code: Locale.current.currency?.identifier ?? "USD")
}

Section {
    Text(totalAmount, format: currencyFormat)
}