← Unit 1 · all exercises
Saved in this browser only

What percentage

Return what percentage the part is of the whole, rounded down to a whole number. 30 out of 40 is 75. Multiplying before dividing keeps the answer alive.

int percent(int part, int whole)

Solution.java
Loading editor…
Results

Examples

  • percent(30, 40) → 75
  • percent(1, 2) → 50

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