Skip to content

Instantly share code, notes, and snippets.

@AnisahTiaraPratiwi
Created March 20, 2021 10:08
Show Gist options
  • Save AnisahTiaraPratiwi/9d0e5b766bd9d8d65f8632ac956bcc6e to your computer and use it in GitHub Desktop.
Save AnisahTiaraPratiwi/9d0e5b766bd9d8d65f8632ac956bcc6e to your computer and use it in GitHub Desktop.
In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends decide to split the bill evenly between them, after adding 15% tip for the service. Calculate the tip, the total amount to pay, and each friend's share, then output a message saying "Each person needs to pay: " followed by …
bill = 47.28
tip = 0.15 * bill
total = bill + tip
share = total/2
print("Each person needs to pay: " + str (share))
@Harsh652-cpu
Copy link

Great work!

@ryuk971
Copy link

ryuk971 commented Jan 15, 2022

really worked thankyoy

@Himanshu-maxx
Copy link

Thnx!

@sahillangoo
Copy link

bill = 47.28
tip = ((bill * 15)/100)
total = bill + tip
share = total/2
print("Each person needs to pay:" + str(share))

@MaxPowerFol
Copy link

bill = 47.28
tip = (bill * 15)/100
total = bill + tip
share = total/2
print("Each person needs to pay:" + str(share))

@asm-dev
Copy link

asm-dev commented Oct 7, 2022

bill = 47.28
tip = bill * 0.15
total = bill + tip
share = total / 2
print(f"Each person needs to pay: {share}")

@Zamanashrafofficial
Copy link

bill = 47.28
tip = 0.15 * bill
total = bill + tip
share = total/2
print("Each person needs to pay: " + str (share))

@Shubhamwit
Copy link

Fair Share Settlement

You and K of your friends gather for dinner at a restaurant, and the total bill is Rs. V. You pay the entire bill, and since everyone shared the food equally, the bill needs to be split evenly among you all.

After asking your friends to reimburse their fair shares, each person pays you back. However, if the amount to be paid back wasn't an integer, they round down to the previous integer value. For example, if each friend should have paid Rs. 13.2, they instead pay Rs. 13. Even if they should have paid Rs. 13.79, they still only pay Rs. 13, rounding down.

Calculate the net amount that you ended up paying after everyone settles their debts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment