🛠️ToolsShed

小费计算器

计算小费金额,并支持多人分摊。

$
1

TipCalculator.resultsTitle

TipCalculator.tipAmount
$0.00
15%
TipCalculator.totalAmount
$0.00
TipCalculator.billPlusTip
TipCalculator.billSubtotal$0.00
TipCalculator.tipRow (15%)$0.00
TipCalculator.totalRow$0.00

小费计算器快速计算在餐厅、酒吧、酒店或任何预期给予小费的服务中应该给多少小费。输入账单总额,选择小费百分比(或设置自定义金额),可选择在多人之间分摊结果——工具显示小费金额、每人合计和总计。

小费习惯因国而异。在美国,餐厅服务的标准小费为 15-20%,而许多欧洲国家在账单中包含服务费或期望 5-10% 的小额小费。旅行时,此计算器帮助您快速适应当地习惯。

您也可以反向使用该工具:输入含小费的总额和人数,即可查看每个人应付多少。这对于在订单大小不同的群体中公平分摊餐厅账单特别有用。

常见问题

代码实现

def calculate_tip(bill: float, tip_percent: float, num_people: int = 1) -> dict:
    """Calculate tip and split the bill."""
    tip_amount = bill * (tip_percent / 100)
    total = bill + tip_amount
    per_person = total / num_people
    tip_per_person = tip_amount / num_people
    return {
        "bill": bill,
        "tip_amount": tip_amount,
        "total": total,
        "per_person": per_person,
        "tip_per_person": tip_per_person,
        "tip_percent": tip_percent,
        "num_people": num_people,
    }

# Example: $85 bill, 18% tip, split 4 ways
result = calculate_tip(bill=85.00, tip_percent=18, num_people=4)
print(f"Bill:           ${result['bill']:.2f}")
print(f"Tip (18%):      ${result['tip_amount']:.2f}")
print(f"Total:          ${result['total']:.2f}")
print(f"Per Person:     ${result['per_person']:.2f}")
print(f"Tip Per Person: ${result['tip_per_person']:.2f}")

# Quick tip reference table
print("\nTip Reference:")
for pct in [10, 15, 18, 20, 25]:
    tip = bill_amount = 85 * pct / 100
    print(f"  {pct}%: ${tip:.2f} tip, ${85 + tip:.2f} total")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.