Question: IN JAVA Write a method called updateTally, which calls nthDigit. updateTally takes in three arguments, an int n, an int num, and an int[] tally.

IN JAVA Write a method called updateTally, which calls nthDigit. updateTally takes in three arguments, an int n, an int num, and an int[] tally. We assume that tally is a int[] of 10 integers. The tally contains the tally of the number of n th digits seen so far. It updates tally to reflect the n th digit of num. In other words, if 5 is the n th digit of num, we increment index 5 of tally. If 2 is the n th digit of num, we increment index 2 of tally. If d is the n th digit of num, we increment index d of tally. Examples showing how tally changes:

updateTally(2, 1072, [0,0,1,2,0,0,3,0,9,0]) [0,0,1,2,0,0,3,1,9,0]

updateTally(0, 2541, [0,0,1,2,0,0,3,0,9,0]) [0,0,2,2,0,0,3,0,9,0]

Remember, since we are modifying tally, updateTally will be a void method which returns nothing.

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!