Results 1 to 1 of 1
  1. #1
    Reii5512 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default The Number System Converter

    hi, can you guys help me out? please :(
    i am stuck at this part. it only print out the first letter A and letter E how do i make it combine all the letter? like the picture?


    import java.util.Scanner;

    public class Lab16MATH05st
    {
    public static void main (String args[])
    {
    System.out.println("Lab16MATH05 - Number Conversion Program\n\n");

    // The next 2 lines are used in all versions.
    System.out.println("ABCD1234 Base-16 converts to " + BaseConverter.fromHexToBin("ABCD1234") + " in Base-2.\n");
    System.out.println("E12B47F5 Base-16 converts to " + BaseConverter.fromHexToBin("E12B47F5") + " in Base-2.\n");

    // The next 2 lines are used in the 90-point versions and above.
    // System.out.println("1011111011101111 Base-2 converts to " + BaseConverter.fromBinToDec("1011111011101111") + " in Base-10.\n");
    // System.out.println("11100100100110110 Base-2 converts to " + BaseConverter.fromBinToDec("11100100100110110") + " in Base-10.\n");

    // The next line is used in the 95-point versions and above.
    // System.out.println("1011111011101111 Base-2 converts to " + BaseConverter.fromBinToHex("1011111011101111") + " in Base-16.\n");

    // The next line is used in the 100-point versions and above.
    // System.out.println("11100100100110110 Base-2 converts to " + BaseConverter.fromBinToHex("11100100100110110") + " in Base-16.\n");

    // The next 3 lines are used in the 105 and 110-point versions.
    // System.out.println("1000 Base-10 converts to " + BaseConverter.fromDecToAny(1000,5) + " in Base-5.\n");
    // System.out.println("1000 Base-10 converts to " + BaseConverter.fromDecToAny(1000,8) + " in Base-8.\n");
    // System.out.println("200 Base-10 converts to " + BaseConverter.fromDecToAny(200,2) + " in Base-2.\n");

    // This last line is only used in the 110 point version.
    // System.out.println("48879 Base-10 converts to " + BaseConverter.fromDecToAny(48879,16) + " in Base-16.\n");
    }
    }


    class BaseConverter
    {
    public static String fromHexToBin(String hexNum)
    {
    String binNum = "";

    for (int k = 0; k < hexNum.length()-0; k++)
    {

    switch (hexNum.charAt(k))
    {
    case '0' : binNum = "0000" ; break;
    case '1' : binNum = "0010" ; break;
    case '3' : binNum = "0011" ; break;
    case '4' : binNum = "0100" ; break;
    case '5' : binNum = "0101" ; break;
    case '6' : binNum = "0110" ; break;
    case '7' : binNum = "0111" ; break;
    case '8' : binNum = "1000" ; break;
    case '9' : binNum = "1001" ; break;
    case 'A' : binNum = "1010" ; break;
    case 'B' : binNum = "1011" ; break;
    case 'C' : binNum = "1100" ; break;
    case 'D' : binNum = "1101" ; break;
    case 'E' : binNum = "1110" ; break;
    case 'F' : binNum = "1111" ; break;
    }
    return binNum;
    }
    return hexNum;

    }

    --------------------Configuration: <Default>--------------------
    Lab16MATH05 - Number Conversion Program


    ABCD1234 Base-16 converts to 1010 in Base-2.

    E12B47F5 Base-16 converts to 1110 in Base-2.


    Process completed.
    Attached Thumbnails Attached Thumbnails The Number System Converter-80.png  

Similar Threads

  1. Number System Converter
    By SneakerIntel in forum New To Java
    Replies: 7
    Last Post: 02-07-2014, 07:15 PM
  2. Replies: 2
    Last Post: 03-02-2013, 03:24 AM
  3. octal and hexadecimal number system
    By boundless in forum New To Java
    Replies: 1
    Last Post: 03-01-2013, 02:55 PM
  4. counting number of lines of system.out
    By IYIaster in forum New To Java
    Replies: 1
    Last Post: 07-21-2009, 12:37 AM
  5. Auto generated number system?
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 08-09-2008, 05:16 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
  •