← Unit 2 · all exercises
Saved in this browser only

Eligible to vote

Someone can vote when they are 18 or older AND registered. Return true only when both hold.

boolean canVote(int age, boolean registered)

Solution.java
Loading editor…
Results

Examples

  • canVote(20, true) → true
  • canVote(20, false) → false

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