← Unit 1 · all exercises
Saved in this browser only

Add a tip

Start with the bill, add the tip to it using +=, and return the total. Both are in whole cents.

int withTip(int bill, int tip)

Solution.java
Loading editor…
Results

Examples

  • withTip(1000, 150) → 1150
  • withTip(500, 0) → 500

There are also 3 hidden tests you can't see. Solve the problem, not the examples.