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

 

jebbert@volusia.k12.fl.us > test2024_01_22_APP1SLHL_countDigits
prev  |  next  |  chance

Write a method that returns the number of times 'digit' appears in 'num'. As preconditions you may assume that 'num' is positive and that 'digit' is a single non-negative digit (but could be zero). You are NOT allowed to use arrays or strings in solving this problem! Recursion IS allowed, but not required.


test2024_01_22_APP1SLHL_countDigits(70000, 0) → 4
test2024_01_22_APP1SLHL_countDigits(40010, 0) → 3
test2024_01_22_APP1SLHL_countDigits(12535, 5) → 2

...Save, Compile, Run (ctrl-enter)

public int test2024_01_22_APP1SLHL_countDigits(int num, int digit) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 245

Copyright Nick Parlante 2017 - privacy