Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

To implement Hamming code with random noise error and calculate the percentage of correcting errors singlebit error burst error you can modify the exi... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago