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

 

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

Write a method that accepts three bits of a binary number as Boolean input parameters. Bit 0 is the least significant bit (the one's place). Bit 1 is the 2's place and bit 2 is the 4's place. Return an integer that has the value of that binary representation. So, for example, if bit2 is 'true'; bit1 is 'true' and bit0 is 'false' that represents the binary number 110. That number has a decimal value of 6, so you would return a 6. Look at the test data for additional examples. Please only use ONE return statement! (This means you will need to make a variable to temporarily store the results).


fromBinaryUCF(false, false, false) → 0
fromBinaryUCF(false, false, true) → 1
fromBinaryUCF(false, true, false) → 2

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

public int fromBinaryUCF(boolean bit2, boolean bit1, boolean bit0) { }

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: 100

Copyright Nick Parlante 2017 - privacy