Results 1 to 2 of 2
 11192013, 10:00 PM #1Member
 Join Date
 Nov 2013
 Posts
 22
 Rep Power
 0
Program Using Arrays To Conver Binary to Decimal and Decimal to Binary.
I am in a AP Computer Science class and have an assignment that I have NO CLUE how to do. I will post the instructions below. Can someone throw together a fast code that I can base mine off of please.
__________________________________________________ __________________________________
In this project, we’re going to revisit the concept of binary numbers and base conversions with the use of arrays. The goal
is going to be to design a program that will ask the user if they would like to convert from binary to decimal (or vice versa),
and the program will generate the appropriate output.
Create a Java Project in Eclipse called Binary Numbers. Create a class called BinaryNumbers, and make sure it has
the main method.
There are several algorithms for converting a decimal number to binary, but the one most commonly used seems to follow
this strategy:
Decimal Number: 170
Largest power of two not exceeding the decimal number: 128
Is 128 in 170? Yep! Put a 1 in that place and subtract 128 => 42
Is 64 in 42? Nope.
Is 32 in 42? Yep! Put a 1 in that place and subtract 32 => 10
Is 16 in 10? Nope.
Is 8 in 10? Yep! Put a 1 in that place and subtract 8 => 2
Is 4 in 2? Nope.
Is 2 in 2? Yep! Put a 1 in that place and subtract 2 => 0
We’re down to zero left, so we must be done!
 11192013, 10:25 PM #2
Re: Program Using Arrays To Conver Binary to Decimal and Decimal to Binary.
What have you tried?  Matt Gemmell
Post your code and specific questions about the problems you are having?If you don't understand my response, don't ignore it, ask a question.
Similar Threads

Binary to Decimal
By Nightcrawler in forum New To JavaReplies: 3Last Post: 03052012, 02:45 AM 
Advice On First Program (binary to decimal converter)
By HandMeTheBacon in forum New To JavaReplies: 0Last Post: 09132011, 03:35 AM 
anyone know's how to program a conversion of binarydecimal , decimalbinary
By irnie1994 in forum JCreatorReplies: 5Last Post: 08252011, 07:32 PM 
Decimal to binary, octal to decimal
By matejm1994 in forum New To JavaReplies: 3Last Post: 12262010, 09:59 AM
Bookmarks