Question: Problem # 4 : Shopping Spree Isabel is going shopping using her debit card and has a tendency to overspend. Complete the function, balance _
Problem #: Shopping Spree
Isabel is going shopping using her debit card and has a tendency to overspend. Complete the function, balanceremaining, which takes two arguments: initial, the integer amount of money Isabel starts with in her account; and transactions, the list of purchases Isabel is charging to her card.
Each transaction in the transactions list is a string of the following format:
'Store Name $price'
The price is always an integer.
If Isabel can afford all of her transactions, your function should return the string
'Balance Remaining: $balance'
where balance is her remaining balance. If Isabel attempts to overspend, cancel the transaction ie dont subtract the transaction amount from her current balance and return the string
'Declined at Store Name: $balance'
where Store Name is the name of the store where her charge was declined, and balance is the amount of money she has remaining.
Function Call
Expected Return Value string
balanceremaining
Best Buy $ 'Five Guys $
Balance Remaining: $
balanceremaining
Forever $ 'Hollister $
The Disney Store $ 'Starbucks $
Balance Remaining: $
balanceremaining
Hallmark $ 'Stop and Shop $
'Taco Bell $
Declined at Taco Bell: $
balanceremaining
Hot Topic $ 'Hollister $
'Five Guys $
Declined at Hollister: $
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
