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

 

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

Write a method that counts how many times the digit 'targetDigit' appears within the positive integer parameter 'origNum'. The parameter 'targetDigit' will be a single non-negative integer. The parameter 'origNum' could be any positive integer. For example, if 'origNum' is 712114 and 'targetDigit' is 1, this method should return 3 since the digit 1 appears three times in the number 712114. Please note that you are NOT allowed to use ANY strings in solving this problem. Hint: Don't forget about the 'div' and 'mod' operators: / and % as these will be very helpful.


nov4_2016_APSLHL_countDigits(5432, 4) → 1
nov4_2016_APSLHL_countDigits(78077, 7) → 3
nov4_2016_APSLHL_countDigits(78077, 8) → 1

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

public int nov4_2016_APSLHL_countDigits(int origNum, int targetDigit) { }

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: 250

Copyright Nick Parlante 2017 - privacy