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_APSLHL_binaryArray
prev  |  next  |  chance

Write a method that accepts 'binaryDigits' which indicates how many digits are wanted for an unsigned binary number, and 'deciNum' which is the non-negative decimal number to be converted to binary. Return an array with either a 1 or 0 in each position so that when read from left to right the array represents 'deciNum' in binary. If the value of 'deciNum' is too great to fit in 'binaryDigits' of binary digits, 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_APSLHL_binaryArray(4, 7) → [0, 1, 1, 1]
may_14_2019_APSLHL_binaryArray(8, 16) → [0, 0, 0, 1, 0, 0, 0, 0]
may_14_2019_APSLHL_binaryArray(2, 1) → [0, 1]

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

public int[] may_14_2019_APSLHL_binaryArray(int binaryDigits, 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