converting number systems in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ria3
    New Member
    • Mar 2007
    • 8

    #1

    converting number systems in java

    Hi,

    I have to write a program that will alow the user to specify a number (decimal, binary, or hexadecimal) and a base to convert to (decimal, binary, or hexadecimal) using subroutine methods and menu - so that the user can choose their options.

    I know how to convert with these number systems on paper using a pencil. However, I am not sure how to covert them in a java program. (I am using ready to program). Is there a formula I could use? Like, to find the square of x, I can do sqrt x.. is there something similar for converting these number systems? If not, how can I do it in java?

    I would appreciate any advice you could give me very much.

    Thank you!!
  • ria3
    New Member
    • Mar 2007
    • 8

    #2
    Any links so that I could learn how to do this would also be helpful.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by ria3
      Any links so that I could learn how to do this would also be helpful.
      What do you need sqrt for? You said you just want to convert between number bases. That does not require sqrt. If you know the methods then write down an algorithm for converting a number from a given base n to any base m. Then just convert that algorithm to a java program.

      Comment

      • hirak1984
        Contributor
        • Jan 2007
        • 316

        #4
        did you try ria?

        it is not that hard .Just think the steps you'd follow while doing conversions
        and write codes accordingly.try it post errors,we are always here.
        good luck.
        Originally posted by ria3
        Any links so that I could learn how to do this would also be helpful.

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          Maybe we can help you understand if you explain to us how you wouble convert a number from one system to another. For example, convert 563 decimal to binary.

          Comment

          • ria3
            New Member
            • Mar 2007
            • 8

            #6
            thanks for the tips guys, i finally got it figured out! :)

            Comment

            Working...