Problem 190848 · easy · Phase 01 Prerequisites & Setup

Split the Bill With Tip

functions · percentages · integer division

A group is splitting a restaurant bill. Write split_bill(cents, tip_percent, people) that returns how many cents each person pays. Add the tip (a percentage of the bill) first, divide equally, and round each share up to the next whole cent so the restaurant is never short-changed.

Examples

Input:  cents = 10000, tip_percent = 15, people = 3
Output: 3834
Explanation: 100.00 + 15% = 115.00; 115.00 / 3 = 38.333..., rounded up to 38.34.

Input:  cents = 2000, tip_percent = 0, people = 4
Output: 500

Input:  cents = 999, tip_percent = 10, people = 1
Output: 1099

Constraints

  • 0 <= cents <= 10**8
  • 0 <= tip_percent <= 100 (an integer)
  • 1 <= people <= 50
  • Return an integer number of cents.

Goals

  • Work in whole cents to avoid float errors
  • Round up with integer arithmetic
Starting Python…