Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

How do you feel about the fact that you did that?

Answered: 1 week ago