about | help | code help+videos | done | prefs |
Write a RECURSIVE method that accepts an array of non-negative single-digit integers, and then returns a double that represents those digits as a double parameter, but with 'decimalPlaces' number of digits AFTER the decimal. For example, a call to this method that passes in [3,8,0,0,5] and a 2 would return the double 380.05. The integer array 'digits' will have at least one integer and each integer will be a 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. If there are leading zeros such as [0,0,0,5,3], the return value does not include those zeros, as long as the 'decimalPlaces' value does not cause leading zeros to be needed as place holders, so, for example, if 'decimalPlaces' is 0, in this case a 53.0 would be returned. Notice that the '.0' at the end is because the return type is a double. Look at the test data for additional examples. may12_2017_SLHL_toNumDeci([3], 0) → 3.0 may12_2017_SLHL_toNumDeci([5, 4, 2, 7, 0, 0, 2], 2) → 54270.02 may12_2017_SLHL_toNumDeci([3, 0, 0, 5, 2, 1], 5) → 3.00521 ...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: 440
Copyright Nick Parlante 2017 - privacy