94.5k views
1 vote
Jeff had $46.18 in his wallet Monday morning. He gave half of his money to his brother. he then bought two donuts for $0.75 each and a cup of coffee for $2.99. How much money did Jeff have left

User Jluk
by
8.5k points

1 Answer

0 votes

Jeff gave his brother $46.18 / 2 = $23.09.

The donuts cost $0.75 x 2 = $1.5.

So, the total cost of the donuts and coffee is $1.5 + $2.99 = $4.49.

Therefore, Jeff has $46.18 - $23.09 - $4.49 = $18.6 left.

-------------------------------------------------------------------------------------------------------------

With coding, we can verify this..

```

def money_left(money_in_wallet, money_given_to_brother, price_of_donuts, price_of_coffee):

"""

This function calculates and returns the amount of money left in Jeff's wallet.

Args:

money_in_wallet: The amount of money Jeff had in his wallet.

money_given_to_brother: The amount of money Jeff gave to his brother.

price_of_donuts: The price of two donuts.

price_of_coffee: The price of a cup of coffee.

Returns:

The amount of money left in Jeff's wallet.

"""

money_spent_on_donuts = price_of_donuts * 2

total_money_spent = money_given_to_brother + money_spent_on_donuts + price_of_coffee

money_left = money_in_wallet - total_money_spent

return money_left

money_in_wallet = 46.18

money_given_to_brother = money_in_wallet / 2

price_of_donuts = 0.75

price_of_coffee = 2.99

money_left = money_left(money_in_wallet, money_given_to_brother, price_of_donuts, price_of_coffee)

print("Jeff has $", money_left, "left.")

```

This code outputs the same answer as the verbal solution: Jeff has $18.6 left.

User Tomfrio
by
8.1k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories