Question: Write a program named ConsecutiveDigits that accepts an integer n from the console and then output the digit in n with the highest number of
Write a program named ConsecutiveDigits that accepts an integer n from the console and then output the digit in n with the highest number of consecutive occurrences. For example, the number 3777785 has four consecutive occurrences of the number 7 and thus the sample output for the program ConsecutiveDigits with input 3777785 should print 4. For many numbers the answer will be 1 because they don't have any adjacent digits that match. Below are sample calls on the method. You are not allowed to use a String to solve this problem. You may assume that the value passed to the method is greater than or equal to 0.
| Input | Output |
| 0 | No output |
| 18 | No output |
| 394 | No output |
| 99 | The number of occurrences of the digit 9 is 2 |
| 8823 | The number of occurrences of the digit 8 is 2 |
| 777 | The number of occurrences of the digit 7 is 3 |
| 82888 | The number of occurrences of the digit 8 is 3 |
| 7111171 | The number of occurrences of the digit 1 is 4 |
| 233333888 | The number of occurrences of the digit 3 is 5 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
