calculate the average daily balance from the following(30-day billing cycle)

7-21 billing date previous balance $400
7-28 payment $40 credit
7-31 charge $60
8-6 payment $10 credit
8-13 cash advance $50

On 7-21 the balance is $400.

It remains $400 for 7 days
On 7-28 the balance becomes $360
It remains $360 for 3 days.
On 7-31 the balance becomes $420
It remains $420 for 6 days
On 8-6, the balance becomes $410
It remains $410 for 7 days
On 8-13 the balance becomes $460
It it remains $460 until the end of the billing cycle (for 7 days)
Average balance =
[400*7 + 360*3 + 420*6 +410*7 +460*7]/30
= $416.33