Question: Write a recursive method called digitMatch that accepts two nonnegative integers as parameters and that returns the number of digits that match between them. Two

Write a recursive method called digitMatch that accepts two nonnegative integers as parameters and that returns the number of digits that match between them. Two digits match if they are equal and have the same position relative to the end of the number (i.e., starting with the ones digit). In other words, the method should compare the last digits of each number, the second-to-last digits of each number, the third-to-last digits of each number, and so forth, counting how many pairs match. For example, for the call of digitMatch(1072503891, 62530841) , the method would compare as follows, and return 4 because four of the pairs match (2-2, 5-5, 8-8, and 1-1).

1 0 7 25 03 891 6 2 5 3 0 8 4 1

1 0 7 25 03 891 6 2 5 3 0 8 4 1

Step by Step Solution

3.40 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static int digitMatch int x int y if x 0 y ... View full answer

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 Building Java Programs A Back to Basics Approach Questions!