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!

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?