The bill with the tip
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- decimals
Problem
Write a function that takes bill and pct, the tip percentage, and returns the total to pay: the bill plus that percentage of the bill.
If pct is 20, the tip is 20% of the bill.
The total is paid in whole dollars: drop the cents by rounding down, never up. So 402.5 becomes 402 and 95.5 becomes 95.
Examples
200, 10 → 220
350, 15 → 402
180, 27 → 228
A bill with cents
123.5, 12 → 138
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def total_with_tip(bill, pct):
passJavaScript
function totalWithTip(bill, pct) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.