Question: In java-Write a function nthDigit, which takes in two ints, n and num, and returns the n th highest order digit of num. In other

In java-Write a function nthDigit, which takes in two ints, n and num, and returns the n th highest order digit of num. In other words, this method returns the n th digit from the left, as opposed to nthDigitBack, which returns the n th digit from the right. The leftmost digit is considered the 0th digit here. Just like nthDigitBack, nthDigit should evaluate to 0 for digits beyond the end of the number.

Think about how to convert the problem of the n th digit from the left into finding the same digit, but going from the right. Example method calls:

nthDigit(0,123) 1

nthDigit(1,123) 2

nthDigit(2,123) 3

nthDigit(3,123) 0

nthDigit(0,0) 0

nthDigit(3,18023) 2

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!