Convert a Char into HammingCode


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Convert a Char into HammingCode

  1. #1
    Join Date
    Sep 2006
    Posts
    2

    Convert a Char into HammingCode

    Hey guys. This is my first Time in these forums. i just started learning java on my own. i just started learning the basics and now all of a sudden this advance programming came in front of me. what i really wanted to do is to convert a character into hammingcode. i am not using any java compiler. i am using secure SSh client to compile java codes with no dialogbox to be displayed. if i enter A it should convert into binary which is 1000010 and then convert it into hammingcode by using paritybits. any help would be really appreciated.
    Thanks

  2. #2
    Join Date
    Sep 2006
    Posts
    2
    This is the following code i am using it will convert an Ascii char to binary but now i am stuck how to convert that binary number into hammingcode.


    public class printBits2{
    public static void main( String args[] ){
    printBits2 pb = new printBits2( args[ 0 ] );

    }

    public printBits2( String message ){
    System.out.print( message + "\n\n" );
    char chA[] = new char[ message.length() ];
    chA = message.toCharArray();

    char displayMask = 1 << 9 ;
    for( int i = 0; i < message.length(); i++ ){
    System.out.print( chA[ i ] );
    // printCharBits( chA[ i ] );
    System.out.print( "\n" );
    }
    }

    // private void printCharBits( char c ) int displayMask = 1 << 9;
    for ( int bit = 1; bit < ; bit++ ){
    if( ( c & displayMask ) == 0 ){
    System.out.print( "0" );
    if( bit % 7 == 0 ){ System.out.print( " " ); }
    }
    /* else{
    System.out.print( "1" );
    if( bit % 7 == 0 ){ System.out.print( " " ); }
    }
    c <<= 1;
    } */ System.out.print( "\n" );
    }
    }

    ~

Similar Threads

  1. Runtime error w/ Variable Type Part II
    By jamestmfbong in forum C++
    Replies: 2
    Last Post: 05-04-2009, 06:03 PM
  2. Replies: 9
    Last Post: 07-28-2005, 08:40 PM
  3. VB/C Array parameters
    By Gastao Woelfert in forum VB Classic
    Replies: 2
    Last Post: 09-01-2000, 11:36 AM
  4. VB/C Array parameters
    By Gastao Woelfert in forum VB Classic
    Replies: 0
    Last Post: 09-01-2000, 08:59 AM
  5. Convert char data to date
    By wang in forum Database
    Replies: 1
    Last Post: 05-19-2000, 05:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center