about | help | code help+videos | done | prefs |
Write a method that returns the specified digit 'digitNum' in the number 'num'. For example, if num=123456 and digitNum=2, return a 5 since 5 is the second digit (counting from the right). So the one's place is digit number 1, the ten's place is digit number 2, etc. If digitNum is greater than the number of digits in the number, return a zero. Look at the test data for further examples. You may choose to use the Math.pow operator. That operator returns a double, so you may need to type-cast it to int. Or you can choose to write your own helper-method for finding powers of ten. As preconditions, you may assume that num>0 and digitNum>0. mar27_2017_APSLHL_getDigit(1042578, 7) → 1 mar27_2017_APSLHL_getDigit(457, 1) → 7 mar27_2017_APSLHL_getDigit(82493, 2) → 9 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy