Question: import java.util.Scanner; class HammingCode { static void print ( int ar [ ] ) { for ( int i = 1 ; i < ar

import java.util.Scanner;
class HammingCode {
static void print(int ar[]){
for (int i =1; i < ar.length; i++){
System.out.print(ar[i]);
}
System.out.println();
}
static int[] calculation(int[] ar, int r){
for (int i =0; i < r; i++){
int x =(int) Math.pow(2, i);
for (int j =1; j < ar.length; j++){
if (((j >> i) & 1)==1){
if (x != j)
ar[x]= ar[x]^ ar[j];
}
}
System.out.println("p"+ x +"="+ ar[x]);
}
return ar;
}
static int[] generateCode(String str, int M, int r){
int[] ar = new int[r + M +1];
int j =0;
for (int i =1; i < ar.length; i++){
if ((Math.ceil(Math.log(i)/ Math.log(2))
- Math.floor(Math.log(i)/ Math.log(2)))
==0){
ar[i]=0;
} else {
ar[i]=(int)(str.charAt(j)-'0');
j++;
}
}
return ar;
}
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
// Input message from the user
System.out.print("Enter Data: ");
String str = scanner.nextLine();
int M = str.length();
int k =1;
//2^K -1>= M + K
while ((-1+Math.pow(2, k))<(M + k )){
k++;
}
int[] ar = generateCode(str, M, k);
System.out.println("Generated hamming code ");
ar = calculation(ar, k);
print(ar);
scanner.close();
}
}..you must do this hamming code (with random) noise (error).
you must calculate the percentage of correcting error (single bit error, burst error). you must do it to check and correct large data

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement Hamming code with random noise error and calculate the percentage of correcting errors singlebit error burst error you can modify the exi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!