Results 1 to 2 of 2
  1. #1
    CreatingDrake is offline Member
    Join Date
    Nov 2013
    Posts
    22
    Rep Power
    0

    Default 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!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default 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

  1. Binary to Decimal
    By Nightcrawler in forum New To Java
    Replies: 3
    Last Post: 03-05-2012, 02:45 AM
  2. Advice On First Program (binary to decimal converter)
    By HandMeTheBacon in forum New To Java
    Replies: 0
    Last Post: 09-13-2011, 03:35 AM
  3. Replies: 5
    Last Post: 08-25-2011, 07:32 PM
  4. Decimal to binary, octal to decimal
    By matejm1994 in forum New To Java
    Replies: 3
    Last Post: 12-26-2010, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •