Lesson 6 Challenge

Hi. I don’t understand why there is a number ‘1’ in the calculation to find the split in lesson 6’s challenge (1 + tax). Can anyone help explain this? Thank you so much.

4 people have dinner and want to split the bill.
Calculate the total with tax and then how much each person owes.
Assign it to the variable, ‘split’ and then print it out to the console area.

let people:Double = 4
let subtotal:Double = 128
let tax = 0.13
var split:Double = 0

// Solution
split = (subtotal * (1 + tax))/people


Hi Erica,

Welcome to the Code Crew community.

The tax rate is a decimal value so if you multiply the subtotal by just that value you end up with the proportion of the subtotal equating to how much tax is applied.

So 128 * 0.13 = 16.64.

If you add 1 to that tax value and then multiply the subtotal by that you get a result which equates to the subtotal plus the tax amount.

So 128 * 1.13 = 144.64.

If you then divide that result by the number of people (in this case 4) you get 36.16

Does that make sense?

Hi Chris,

Thank you ever so much for that, and how quickly you got in touch.

I understand better now, thank you. Now it’s clear. That’s great.

Have a wonderful rest of your day.