Results 1 to 2 of 2
  1. #1
    dojob is offline Member
    Join Date
    Jul 2013
    Posts
    52
    Rep Power
    0

    Default Enter input as string or int ??

    I have discovered this question which I unclear of what the question want for the data type of the input value.

    Write a method that parses a binary number into a hex number.
    The method header is as follows:
    Java Code:
    public static String binaryToHex(String binaryValue)
    Write a test program that prompts the user to enter a binary number and displays the corresponding hexadecimal value.
    Should we take the input as int and convert it to String based on the question or just take the input as String?
    Last edited by dojob; 09-22-2013 at 03:26 AM.

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,501
    Rep Power
    5

    Default Re: Enter input as string or int ??

    Definitely read it in as a String. You should probably check to ensure it is binary (i.e. only has 1's and 0's). And there are methods for doing that. Check out the Integer API.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. enter a string sentence
    By amorosa19 in forum New To Java
    Replies: 13
    Last Post: 09-06-2013, 10:34 AM
  2. Replies: 1
    Last Post: 07-25-2013, 09:15 PM
  3. Replies: 1
    Last Post: 01-30-2012, 04:41 AM
  4. how to enter input method name for getMethod(------)
    By Dayanand in forum New To Java
    Replies: 3
    Last Post: 02-23-2011, 06:07 PM
  5. need help in string to input
    By eyeore in forum New To Java
    Replies: 4
    Last Post: 01-11-2010, 11:07 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
  •