id/email
password
forgot password
about | help | done | prefs | create account
CodingBat code practice

Java > AP-1 > hasOne
prev  |  next  |  chance

Given a positive int n, return true if it contains a 1 digit. Note: use % to get the rightmost digit, and / to discard the rightmost digit.

hasOne(10) → true
hasOne(22) → false
hasOne(220) → false

...Save, Compile, Run

See also Java Example Code. Java help docs: If Boolean Logic | Strings | While and For Loops | Arrays and Loops


prev  |  next  |  chance   |  CodingBat  >  AP-1

Forget It! -- delete my code for this problem 224.0

Copyright Nick Parlante 2006-10 - privacy