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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started