Hamming Code

Download as pdf
Download as pdf
You are on page 1of 9
import java.util dass Harnmingcode { public static void main(String args{]) ( Scanner scan = new Scanner{System.in); System.out.printin("Enter the number of bits for the Hamming data "y int n= scan.nextint(); int al] = new intin]; for(int i=0 ji 0 if(Math.pow(2, power) system.out.print(ali- } system.out.printin(); seseeeeeeeee HOH OUTPUTH HH sactceceeess ricrosoft Windows [Version 6.3.9600] 013 Microsoft Corporation. All rights reserved a2 cusers\SSICOEI> ca, crpedteb cAteboset pat! rogram Files\Java\jdk1.8.0_192\bin C.\teb>javac HammingCode.java c:\teb>java HammingCode Enter the number of bits for the Hammi; 7 Enter bit no. 7: 1 Enter bit Enter bit no. 5: 1 Enter bit no. 4: ° Enter bit no. 3: 1 enter bit nO: 2 o enterbit no. 2: 1 you entered: 3010101 Generated code is: 40100101111. Enter position of a bit to alti ‘0 check for error detecti jon at the receiver en 4 (0 for no error): 5 sent code is: so100111111 Error is at location 5. Corrected code is:

You might also like