Question: Write a method digitCount(int number, int digit) which takes an integer (it could be negative) and a digit (between 0 and 9), and returns the

Write a method digitCount(int number, int digit) which takes an integer (it could be negative) and a digit (between 0 and 9), and returns the number of times the given digit occurs in the given integer. You may not convert the numbers to strings here. Solve this problem numerically.

digitCount(456234, 8) returns 0

digitCount(456234, 5) returns 1

digitCount(456234, 4) returns 2

digitCount(-456234, 4) returns 2

digitCount(0, 0) returns 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!