id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > may_14_2019_SLHL_baseArray
prev  |  next  |  chance

Write a method that accepts 'baseDigits' which indicates how many digits are wanted for an unsigned number in the base 'base'. The base will be a number between 2 and 10 inclusive. The input parameter 'deciNum' is the non-negative decimal number to be converted to the given base. Return an array with digits from 'base' in each position so that when read from left to right the array represents 'deciNum' in that base. If the value of 'deciNum' is too great to fit in 'baseDigits' of digits in that base, return an empty array of length zero. (This part is a little tricky!) Look at the test data for examples. You MAY copy-and-paste code from other problems from THIS test only if you want.


may_14_2019_SLHL_baseArray(2, 16, 7000) → [0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0]
may_14_2019_SLHL_baseArray(2, 4, 50) → []
may_14_2019_SLHL_baseArray(2, 31, 260000000) → [0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]

...Save, Compile, Run (ctrl-enter)

public int[] may_14_2019_SLHL_baseArray(int base, int baseDigits, int deciNum) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy